projects
/
dos_imgv
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
check alloc
[dos_imgv]
/
imago
/
src
/
imago2.c
diff --git
a/imago/src/imago2.c
b/imago/src/imago2.c
index
77bf7f0
..
b4ec465
100644
(file)
--- a/
imago/src/imago2.c
+++ b/
imago/src/imago2.c
@@
-21,6
+21,7
@@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#include "imago2.h"
#include "ftmodule.h"
#include <string.h>
#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);
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)
{
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;
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;
}
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);
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);
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;
}
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);
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);
void *newpix;
int pixsz = pixel_size(fmt);
- if(!(newpix = malloc(w * h * pixsz))) {
+ if(!(newpix = chk_malloc(w * h * pixsz))) {
return -1;
}
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);
}
memset(newpix, 0, w * h * pixsz);
}
- free(img->pixels);
+ chk_free(img->pixels);
img->pixels = newpix;
img->width = w;
img->height = h;
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)
{
void img_free_pixels(void *pix)
{
- free(pix);
+ chk_free(pix);
}
int img_load(struct img_pixmap *img, const char *fname)
}
int img_load(struct img_pixmap *img, const char *fname)