From: Lutz M. <lu...@us...> - 2004-10-04 06:27:11
|
Update of /cvsroot/libexif/libexif/libexif/olympus In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10678/libexif/olympus Modified Files: exif-mnote-data-olympus.c exif-mnote-data-olympus.h Log Message: 2004-10-04 Lutz Mueller <lu...@us...> * libexif/*: Finish replaceable memory-management. Index: exif-mnote-data-olympus.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/olympus/exif-mnote-data-olympus.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- exif-mnote-data-olympus.h 11 May 2004 15:11:17 -0000 1.3 +++ exif-mnote-data-olympus.h 4 Oct 2004 06:26:59 -0000 1.4 @@ -24,6 +24,7 @@ #include <libexif/exif-mnote-data-priv.h> #include <libexif/olympus/mnote-olympus-entry.h> #include <libexif/exif-byte-order.h> +#include <libexif/exif-mem.h> typedef struct _ExifMnoteDataOlympus ExifMnoteDataOlympus; @@ -39,6 +40,6 @@ int version; }; -ExifMnoteData *exif_mnote_data_olympus_new (void); +ExifMnoteData *exif_mnote_data_olympus_new (ExifMem *); #endif /* __MNOTE_OLYMPUS_CONTENT_H__ */ Index: exif-mnote-data-olympus.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/olympus/exif-mnote-data-olympus.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- exif-mnote-data-olympus.c 12 Sep 2004 19:52:39 -0000 1.19 +++ exif-mnote-data-olympus.c 4 Oct 2004 06:26:59 -0000 1.20 @@ -33,6 +33,7 @@ static void exif_mnote_data_olympus_clear (ExifMnoteDataOlympus *n) { + ExifMnoteData *d = (ExifMnoteData *) n; unsigned int i; if (!n) return; @@ -40,10 +41,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; } @@ -86,9 +87,8 @@ *buf_size = 6 + 2 + 2 + n->count * 12; switch (n->version) { case 0: /* Olympus */ - *buf = malloc (*buf_size); + *buf = exif_mem_alloc (ne->mem, *buf_size); if (!*buf) return; - memset (*buf, 0, *buf_size); /* Write the header and the number of entries. */ strcpy (*buf, "OLYMP"); @@ -101,9 +101,8 @@ /* Fall through */ case 2: /* Nikon v2 */ *buf_size += 8; - *buf = malloc (*buf_size); + *buf = exif_mem_alloc (ne->mem, *buf_size); if (!*buf) return; - memset (*buf, 0, *buf_size); /* Write the header and the number of entries. */ strcpy (*buf, "Nikon"); @@ -267,9 +266,8 @@ /* Read the number of entries and remove old ones. */ exif_mnote_data_olympus_clear (n); - n->entries = malloc (sizeof (MnoteOlympusEntry) * c); + n->entries = exif_mem_alloc (en->mem, sizeof (MnoteOlympusEntry) * c); if (!n->entries) return; - memset (n->entries, 0, sizeof (MnoteOlympusEntry) * c); /* Parse the entries */ for (i = 0; i < c; i++) { @@ -298,7 +296,7 @@ if (o + s > buf_size) continue; /* Sanity check */ - n->entries[i].data = malloc (s); + n->entries[i].data = exif_mem_alloc (en->mem, s); if (!n->entries[i].data) continue; n->entries[i].size = s; memcpy (n->entries[i].data, buf + o, s); @@ -428,14 +426,16 @@ } ExifMnoteData * -exif_mnote_data_olympus_new (void) +exif_mnote_data_olympus_new (ExifMem *mem) { ExifMnoteData *d; - d = calloc (1, sizeof (ExifMnoteDataOlympus)); + if (!mem) return NULL; + + d = exif_mem_alloc (mem, sizeof (ExifMnoteDataOlympus)); 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_olympus_free; |