X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=imago%2Fsrc%2Fimago2.c;h=b4ec46514755f7a7978d0c00d6d39a527484d1ad;hb=56d0fddeeaee0ecb56cddc09db44bb87bf011314;hp=77bf7f07e626a7736af4c22fc5c3e7ac41d3fa9b;hpb=773592751bbdef2f304725b24f620f89c9d4a5eb;p=dos_imgv
diff --git a/imago/src/imago2.c b/imago/src/imago2.c
index 77bf7f0..b4ec465 100644
--- a/imago/src/imago2.c
+++ b/imago/src/imago2.c
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include
#include "imago2.h"
#include "ftmodule.h"
+#include "chkalloc.h"
static int pixel_size(enum img_fmt fmt);
static size_t def_read(void *buf, size_t bytes, void *uptr);
@@ -40,17 +41,17 @@ void img_init(struct img_pixmap *img)
void img_destroy(struct img_pixmap *img)
{
- free(img->pixels);
+ chk_free(img->pixels);
img->pixels = 0; /* just in case... */
img->width = img->height = 0xbadbeef;
- free(img->name);
+ chk_free(img->name);
}
struct img_pixmap *img_create(void)
{
struct img_pixmap *p;
- if(!(p = malloc(sizeof *p))) {
+ if(!(p = chk_malloc(sizeof *p))) {
return 0;
}
img_init(p);
@@ -60,14 +61,14 @@ struct img_pixmap *img_create(void)
void img_free(struct img_pixmap *img)
{
img_destroy(img);
- free(img);
+ chk_free(img);
}
int img_set_name(struct img_pixmap *img, const char *name)
{
char *tmp;
- if(!(tmp = malloc(strlen(name) + 1))) {
+ if(!(tmp = chk_malloc(strlen(name) + 1))) {
return -1;
}
strcpy(tmp, name);
@@ -94,7 +95,7 @@ int img_set_pixels(struct img_pixmap *img, int w, int h, enum img_fmt fmt, void
void *newpix;
int pixsz = pixel_size(fmt);
- if(!(newpix = malloc(w * h * pixsz))) {
+ if(!(newpix = chk_malloc(w * h * pixsz))) {
return -1;
}
@@ -104,7 +105,7 @@ int img_set_pixels(struct img_pixmap *img, int w, int h, enum img_fmt fmt, void
memset(newpix, 0, w * h * pixsz);
}
- free(img->pixels);
+ chk_free(img->pixels);
img->pixels = newpix;
img->width = w;
img->height = h;
@@ -154,7 +155,7 @@ int img_save_pixels(const char *fname, void *pix, int xsz, int ysz, enum img_fmt
void img_free_pixels(void *pix)
{
- free(pix);
+ chk_free(pix);
}
int img_load(struct img_pixmap *img, const char *fname)