Skip to content

Commit 0f4d15e

Browse files
committed
fix(loader): split builtin wrapper TU to avoid pcc ICE
1 parent 5fd87f4 commit 0f4d15e

3 files changed

Lines changed: 88 additions & 16 deletions

File tree

src/loader-builtin.c

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5714,21 +5714,22 @@ sixel_builtin_load_stbi_path(
57145714
}
57155715

57165716
SIXELSTATUS
5717-
load_with_builtin(
5718-
sixel_chunk_t const *pchunk,
5719-
int fstatic,
5720-
int fuse_palette,
5721-
int reqcolors,
5722-
unsigned char *bgcolor,
5723-
int bgcolor_source,
5724-
int loop_control,
5725-
int start_frame_no_set,
5726-
int start_frame_no_override,
5727-
int enable_cms,
5728-
int bmp_info40_mode,
5729-
sixel_load_image_function fn_load,
5730-
void *context)
5717+
sixel_builtin_load_with_builtin_impl(
5718+
sixel_builtin_load_with_builtin_args_t const *args)
57315719
{
5720+
sixel_chunk_t const *pchunk;
5721+
int fstatic;
5722+
int fuse_palette;
5723+
int reqcolors;
5724+
unsigned char *bgcolor;
5725+
int bgcolor_source;
5726+
int loop_control;
5727+
int start_frame_no_set;
5728+
int start_frame_no_override;
5729+
int enable_cms;
5730+
int bmp_info40_mode;
5731+
sixel_load_image_function fn_load;
5732+
void *context;
57325733
SIXELSTATUS status;
57335734
unsigned char *pixels;
57345735
sixel_frame_t *frame;
@@ -5752,11 +5753,27 @@ load_with_builtin(
57525753
int apply_start_frame;
57535754
int pnm_pixelformat;
57545755

5756+
if (args == NULL) {
5757+
return SIXEL_BAD_ARGUMENT;
5758+
}
5759+
pchunk = args->pchunk;
5760+
fstatic = args->fstatic;
5761+
fuse_palette = args->fuse_palette;
5762+
reqcolors = args->reqcolors;
5763+
bgcolor = args->bgcolor;
5764+
bgcolor_source = args->bgcolor_source;
5765+
loop_control = args->loop_control;
5766+
start_frame_no_set = args->start_frame_no_set;
5767+
start_frame_no_override = args->start_frame_no_override;
5768+
enable_cms = args->enable_cms;
5769+
bmp_info40_mode = args->bmp_info40_mode;
5770+
fn_load = args->fn_load;
5771+
context = args->context;
57555772
status = SIXEL_BAD_INPUT;
57565773
pixels = NULL;
57575774
frame = NULL;
5758-
stb_context = (stbi__context){ 0 };
5759-
ri = (stbi__result_info){ 0 };
5775+
memset(&stb_context, 0, sizeof(stb_context));
5776+
memset(&ri, 0, sizeof(ri));
57605777
chunk_size = 0;
57615778
is_png = 0;
57625779
is_jpeg = 0;

src/loader-builtin.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,31 @@
3333
#include "chunk.h"
3434
#include "loader-component.h"
3535

36+
typedef struct sixel_builtin_load_with_builtin_args {
37+
sixel_chunk_t const *pchunk;
38+
int fstatic;
39+
int fuse_palette;
40+
int reqcolors;
41+
unsigned char *bgcolor;
42+
int bgcolor_source;
43+
int loop_control;
44+
int start_frame_no_set;
45+
int start_frame_no_override;
46+
int enable_cms;
47+
int bmp_info40_mode;
48+
sixel_load_image_function fn_load;
49+
void *context;
50+
} sixel_builtin_load_with_builtin_args_t;
51+
3652
SIXELSTATUS
3753
sixel_loader_builtin_new(
3854
sixel_allocator_t *allocator,
3955
sixel_loader_component_t **ppcomponent);
4056

57+
SIXELSTATUS
58+
sixel_builtin_load_with_builtin_impl(
59+
sixel_builtin_load_with_builtin_args_t const *args);
60+
4161
SIXELSTATUS load_with_builtin(
4262
sixel_chunk_t const *pchunk,
4363
int fstatic,

src/loader-component.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#endif
2828

2929
#include "loader-component.h"
30+
#include "loader-builtin.h"
3031

3132
void
3233
sixel_loader_component_ref(sixel_loader_component_t *component)
@@ -88,6 +89,40 @@ sixel_loader_component_get_name(sixel_loader_component_t const *component)
8889
return component->vtbl->name(component);
8990
}
9091

92+
SIXELSTATUS
93+
load_with_builtin(
94+
sixel_chunk_t const *pchunk,
95+
int fstatic,
96+
int fuse_palette,
97+
int reqcolors,
98+
unsigned char *bgcolor,
99+
int bgcolor_source,
100+
int loop_control,
101+
int start_frame_no_set,
102+
int start_frame_no_override,
103+
int enable_cms,
104+
int bmp_info40_mode,
105+
sixel_load_image_function fn_load,
106+
void *context)
107+
{
108+
sixel_builtin_load_with_builtin_args_t args;
109+
110+
args.pchunk = pchunk;
111+
args.fstatic = fstatic;
112+
args.fuse_palette = fuse_palette;
113+
args.reqcolors = reqcolors;
114+
args.bgcolor = bgcolor;
115+
args.bgcolor_source = bgcolor_source;
116+
args.loop_control = loop_control;
117+
args.start_frame_no_set = start_frame_no_set;
118+
args.start_frame_no_override = start_frame_no_override;
119+
args.enable_cms = enable_cms;
120+
args.bmp_info40_mode = bmp_info40_mode;
121+
args.fn_load = fn_load;
122+
args.context = context;
123+
return sixel_builtin_load_with_builtin_impl(&args);
124+
}
125+
91126
/* emacs Local Variables: */
92127
/* emacs mode: c */
93128
/* emacs tab-width: 4 */

0 commit comments

Comments
 (0)