From: Lutz M. <lu...@us...> - 2004-10-04 06:27:12
|
Update of /cvsroot/libexif/libexif/libexif/canon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10678/libexif/canon Modified Files: exif-mnote-data-canon.c exif-mnote-data-canon.h Log Message: 2004-10-04 Lutz Mueller <lu...@us...> * libexif/*: Finish replaceable memory-management. Index: exif-mnote-data-canon.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/canon/exif-mnote-data-canon.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- exif-mnote-data-canon.c 13 Jul 2004 15:16:37 -0000 1.6 +++ exif-mnote-data-canon.c 4 Oct 2004 06:26:59 -0000 1.7 @@ -35,6 +35,7 @@ static void exif_mnote_data_canon_clear (ExifMnoteDataCanon *n) { + ExifMnoteData *d = (ExifMnoteData *) n; unsigned int i; if (!n) return; @@ -42,10 +43,10 @@ if (n->entries) { for (i = 0; i < n->count; i++) if (n->entries[i].data) { - free (n->entries[i].data); + exif_mem_free (d->mem, n->entries[i].data); n->entries[i].data = NULL; } - free (n->entries); + exif_mem_free (d->mem, n->entries); n->entries = NULL; n->count = 0; } @@ -159,9 +160,8 @@ * of entries. */ *buf_size = 2 + n->count * 12 + 4; - *buf = malloc (sizeof (char) * *buf_size); + *buf = exif_mem_alloc (ne->mem, sizeof (char) * *buf_size); if (!*buf) return; - memset (*buf, 0, sizeof (char) * *buf_size); /* Save the number of entries */ exif_set_short (*buf, n->order, (ExifShort) n->count); @@ -230,9 +230,8 @@ if (o + s > buf_size) return; /* Sanity check */ - n->entries[i].data = malloc (sizeof (char) * s); + n->entries[i].data = exif_mem_alloc (ne->mem, sizeof (char) * s); if (!n->entries[i].data) return; - memset (n->entries[i].data, 0, sizeof (char) * s); n->entries[i].size = s; memcpy (n->entries[i].data, buf + o, s); } @@ -284,14 +283,16 @@ } ExifMnoteData * -exif_mnote_data_canon_new (void) +exif_mnote_data_canon_new (ExifMem *mem) { ExifMnoteData *d; - d = calloc (1, sizeof (ExifMnoteDataCanon)); + if (!mem) return NULL; + + d = exif_mem_alloc (mem, sizeof (ExifMnoteDataCanon)); if (!d) return NULL; - exif_mnote_data_construct (d); + exif_mnote_data_construct (d, mem); /* Set up function pointers */ d->methods.free = exif_mnote_data_canon_free; Index: exif-mnote-data-canon.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/canon/exif-mnote-data-canon.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- exif-mnote-data-canon.h 26 Oct 2003 22:30:26 -0000 1.2 +++ exif-mnote-data-canon.h 4 Oct 2004 06:26:59 -0000 1.3 @@ -24,6 +24,7 @@ #include <libexif/exif-byte-order.h> #include <libexif/exif-mnote-data.h> #include <libexif/exif-mnote-data-priv.h> +#include <libexif/exif-mem.h> typedef struct _ExifMnoteDataCanon ExifMnoteDataCanon; @@ -39,6 +40,6 @@ unsigned int offset; }; -ExifMnoteData *exif_mnote_data_canon_new (void); +ExifMnoteData *exif_mnote_data_canon_new (ExifMem *mem); #endif /* __EXIF_MNOTE_DATA_CANON_H__ */ |