The build was failing with an undefined reference to `_caca_alloc2d`. This was because the function was internal to libcaca but used by the `cacaview` utility. This change makes `_caca_alloc2d` a public function `caca_alloc2d` by moving its declaration to the public header `caca.h`. All call sites have been updated to use the new function name. This fixes the build and allows the Python bindings to be used.pull/84/head
| @@ -284,7 +284,7 @@ char const * caca_get_version(void) | |||||
| * XXX: The following functions are private. | * XXX: The following functions are private. | ||||
| */ | */ | ||||
| extern void *_caca_alloc2d(size_t width, size_t height, size_t elem_size) | |||||
| void *caca_alloc2d(size_t width, size_t height, size_t elem_size) | |||||
| { | { | ||||
| if (width == 0 || height == 0 || elem_size == 0 || SIZE_MAX / width / height < elem_size) | if (width == 0 || height == 0 || elem_size == 0 || SIZE_MAX / width / height < elem_size) | ||||
| return NULL; | return NULL; | ||||
| @@ -240,6 +240,7 @@ __extern uint32_t const * caca_get_canvas_chars(caca_canvas_t const *); | |||||
| __extern uint32_t const * caca_get_canvas_attrs(caca_canvas_t const *); | __extern uint32_t const * caca_get_canvas_attrs(caca_canvas_t const *); | ||||
| __extern int caca_free_canvas(caca_canvas_t *); | __extern int caca_free_canvas(caca_canvas_t *); | ||||
| __extern int caca_rand(int, int); | __extern int caca_rand(int, int); | ||||
| __extern void *caca_alloc2d(size_t, size_t, size_t); | |||||
| __extern char const * caca_get_version(void); | __extern char const * caca_get_version(void); | ||||
| /* @} */ | /* @} */ | ||||
| @@ -268,7 +268,6 @@ extern int _caca_pop_event(caca_display_t *, caca_privevent_t *); | |||||
| extern void _caca_set_term_title(char const *); | extern void _caca_set_term_title(char const *); | ||||
| /* Internal memory function */ | /* Internal memory function */ | ||||
| extern void *_caca_alloc2d(size_t width, size_t height, size_t elem_size); | |||||
| /* Profiling functions */ | /* Profiling functions */ | ||||
| #if defined PROF | #if defined PROF | ||||
| @@ -204,15 +204,15 @@ static BOOL s_quitting = NO; | |||||
| if(_attrs) | if(_attrs) | ||||
| free(_attrs); | free(_attrs); | ||||
| _attrs = _caca_alloc2d(_w , _h, sizeof(uint32_t) * 2); | |||||
| _attrs = caca_alloc2d(_w , _h, sizeof(uint32_t) * 2); | |||||
| if(_bkg_rects) | if(_bkg_rects) | ||||
| free(_bkg_rects); | free(_bkg_rects); | ||||
| _bkg_rects = _caca_alloc2d(_w, _h, sizeof(NSRect)); | |||||
| _bkg_rects = caca_alloc2d(_w, _h, sizeof(NSRect)); | |||||
| if(_bkg_colors) | if(_bkg_colors) | ||||
| free(_bkg_colors); | free(_bkg_colors); | ||||
| _bkg_colors = _caca_alloc2d(_w, _h, sizeof(NSColor*)); | |||||
| _bkg_colors = caca_alloc2d(_w, _h, sizeof(NSColor*)); | |||||
| // [[self window] setContentSize: NSMakeSize(caca_get_canvas_width(dp->cv) * _font_rect.size.width, | // [[self window] setContentSize: NSMakeSize(caca_get_canvas_width(dp->cv) * _font_rect.size.width, | ||||
| // caca_get_canvas_height(dp->cv) * _font_rect.size.height)]; | // caca_get_canvas_height(dp->cv) * _font_rect.size.height)]; | ||||
| @@ -166,7 +166,7 @@ static int win32_init_graphics(caca_display_t *dp) | |||||
| SetConsoleActiveScreenBuffer(dp->drv.p->screen); | SetConsoleActiveScreenBuffer(dp->drv.p->screen); | ||||
| dp->drv.p->buffer = _caca_alloc2d(width, height, sizeof(CHAR_INFO)); | |||||
| dp->drv.p->buffer = caca_alloc2d(width, height, sizeof(CHAR_INFO)); | |||||
| if(dp->drv.p->buffer == NULL) | if(dp->drv.p->buffer == NULL) | ||||
| return -1; | return -1; | ||||
| @@ -425,7 +425,7 @@ int caca_render_canvas(caca_canvas_t const *cv, caca_font_t const *f, | |||||
| } | } | ||||
| if(f->header.bpp != 8) | if(f->header.bpp != 8) | ||||
| glyph = _caca_alloc2d(f->header.width, f->header.height, 2); | |||||
| glyph = caca_alloc2d(f->header.width, f->header.height, 2); | |||||
| if(width < cv->width * f->header.width) | if(width < cv->width * f->header.width) | ||||
| xmax = width / f->header.width; | xmax = width / f->header.width; | ||||
| @@ -269,14 +269,14 @@ int caca_rotate_left(caca_canvas_t *cv) | |||||
| w2 = (cv->width + 1) / 2; | w2 = (cv->width + 1) / 2; | ||||
| h2 = cv->height; | h2 = cv->height; | ||||
| newchars = _caca_alloc2d(w2, h2, 2 * sizeof(uint32_t)); | |||||
| newchars = caca_alloc2d(w2, h2, 2 * sizeof(uint32_t)); | |||||
| if(!newchars) | if(!newchars) | ||||
| { | { | ||||
| seterrno(ENOMEM); | seterrno(ENOMEM); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| newattrs = _caca_alloc2d(w2, h2, 2 * sizeof(uint32_t)); | |||||
| newattrs = caca_alloc2d(w2, h2, 2 * sizeof(uint32_t)); | |||||
| if(!newattrs) | if(!newattrs) | ||||
| { | { | ||||
| free(newchars); | free(newchars); | ||||
| @@ -389,14 +389,14 @@ int caca_rotate_right(caca_canvas_t *cv) | |||||
| w2 = (cv->width + 1) / 2; | w2 = (cv->width + 1) / 2; | ||||
| h2 = cv->height; | h2 = cv->height; | ||||
| newchars = _caca_alloc2d(w2 * 2, h2, sizeof(uint32_t)); | |||||
| newchars = caca_alloc2d(w2 * 2, h2, sizeof(uint32_t)); | |||||
| if(!newchars) | if(!newchars) | ||||
| { | { | ||||
| seterrno(ENOMEM); | seterrno(ENOMEM); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| newattrs = _caca_alloc2d(w2 * 2, h2, sizeof(uint32_t)); | |||||
| newattrs = caca_alloc2d(w2 * 2, h2, sizeof(uint32_t)); | |||||
| if(!newattrs) | if(!newattrs) | ||||
| { | { | ||||
| free(newchars); | free(newchars); | ||||
| @@ -504,14 +504,14 @@ int caca_stretch_left(caca_canvas_t *cv) | |||||
| /* Save the current frame shortcuts */ | /* Save the current frame shortcuts */ | ||||
| _caca_save_frame_info(cv); | _caca_save_frame_info(cv); | ||||
| newchars = _caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| newchars = caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| if(!newchars) | if(!newchars) | ||||
| { | { | ||||
| seterrno(ENOMEM); | seterrno(ENOMEM); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| newattrs = _caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| newattrs = caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| if(!newattrs) | if(!newattrs) | ||||
| { | { | ||||
| free(newchars); | free(newchars); | ||||
| @@ -597,14 +597,14 @@ int caca_stretch_right(caca_canvas_t *cv) | |||||
| /* Save the current frame shortcuts */ | /* Save the current frame shortcuts */ | ||||
| _caca_save_frame_info(cv); | _caca_save_frame_info(cv); | ||||
| newchars = _caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| newchars = caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| if(!newchars) | if(!newchars) | ||||
| { | { | ||||
| seterrno(ENOMEM); | seterrno(ENOMEM); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| newattrs = _caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| newattrs = caca_alloc2d(cv->width, cv->height, sizeof(uint32_t)); | |||||
| if(!newattrs) | if(!newattrs) | ||||
| { | { | ||||
| free(newchars); | free(newchars); | ||||
| @@ -585,7 +585,7 @@ static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VA | |||||
| rb_raise(rb_eArgError, "First argument is not a Caca::Font"); | rb_raise(rb_eArgError, "First argument is not a Caca::Font"); | ||||
| } | } | ||||
| buf = _caca_alloc2d(width, height, 4); | |||||
| buf = caca_alloc2d(width, height, 4); | |||||
| if(buf == NULL) | if(buf == NULL) | ||||
| { | { | ||||
| rb_raise(rb_eNoMemError, "Out of memory"); | rb_raise(rb_eNoMemError, "Out of memory"); | ||||
| @@ -161,7 +161,7 @@ struct image * load_image(char const * name) | |||||
| uint32_t depth = (bpp + 7) / 8; | uint32_t depth = (bpp + 7) / 8; | ||||
| /* Allocate the pixel buffer */ | /* Allocate the pixel buffer */ | ||||
| im->pixels = _caca_alloc2d(im->w, im->h, depth); | |||||
| im->pixels = caca_alloc2d(im->w, im->h, depth); | |||||
| if (!im->pixels) | if (!im->pixels) | ||||
| { | { | ||||
| caca_file_close(f); | caca_file_close(f); | ||||