From: Lutz M. <lu...@us...> - 2004-09-07 20:46:41
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12003/libexif Modified Files: exif-entry.c Log Message: 2004-09-07 Lutz Mueller <lu...@us...> * libexif/exif-entry.c: Use calloc. Hint by Jan Patera <pa...@pi...>. Index: exif-entry.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-entry.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- exif-entry.c 7 Sep 2004 06:15:38 -0000 1.57 +++ exif-entry.c 7 Sep 2004 20:46:31 -0000 1.58 @@ -44,15 +44,15 @@ ExifLog *exif_data_get_log (ExifData *); static void * -exif_entry_malloc (ExifEntry *e, unsigned int i) +exif_entry_alloc (ExifEntry *e, unsigned int i) { void *d; ExifLog *l = NULL; if (!i) return NULL; - /* This is the only call to malloc in this file. */ - d = malloc (i); + /* This is the only call to calloc in this file. */ + d = calloc (i, 1); if (d) return d; if (e && e->parent && e->parent->parent) @@ -67,12 +67,10 @@ { ExifEntry *e = NULL; - e = exif_entry_malloc (e, sizeof (ExifEntry)); + e = exif_entry_alloc (e, sizeof (ExifEntry)); if (!e) return NULL; - memset (e, 0, sizeof (ExifEntry)); - e->priv = exif_entry_malloc (e, sizeof (ExifEntryPrivate)); + e->priv = exif_entry_alloc (e, sizeof (ExifEntryPrivate)); if (!e->priv) { free (e); return NULL; } - memset (e->priv, 0, sizeof (ExifEntryPrivate)); e->priv->ref_count = 1; return (e); @@ -844,8 +842,7 @@ e->components = 1; e->format = EXIF_FORMAT_LONG; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); - if (e->data) memset (e->data, 0, e->size); + e->data = exif_entry_alloc (e, e->size); break; /* SHORT, 1 component, no default */ @@ -873,7 +870,7 @@ e->components = 1; e->format = EXIF_FORMAT_SHORT; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); exif_set_short (e->data, o, 0); break; @@ -884,7 +881,7 @@ e->components = 1; e->format = EXIF_FORMAT_SHORT; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); exif_set_short (e->data, o, 1); break; @@ -894,7 +891,7 @@ e->components = 1; e->format = EXIF_FORMAT_SHORT; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); exif_set_short (e->data, o, 2); break; @@ -903,7 +900,7 @@ e->components = 1; e->format = EXIF_FORMAT_SHORT; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); exif_set_short (e->data, o, 3); break; @@ -911,7 +908,7 @@ e->components = 3; e->format = EXIF_FORMAT_SHORT; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; exif_set_short (e->data, o, 8); exif_set_short ( @@ -925,7 +922,7 @@ e->components = 2; e->format = EXIF_FORMAT_SHORT; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; exif_set_short (e->data, o, 2); exif_set_short ( @@ -940,8 +937,7 @@ e->components = 1; e->format = EXIF_FORMAT_SRATIONAL; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); - if (e->data) memset (e->data, 0, e->size); + e->data = exif_entry_alloc (e, e->size); break; /* RATIONAL, 1 component, no default */ @@ -961,8 +957,7 @@ e->components = 1; e->format = EXIF_FORMAT_RATIONAL; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); - if (e->data) memset (e->data, 0, e->size); + e->data = exif_entry_alloc (e, e->size); break; /* RATIONAL, 1 component, default 72/1 */ @@ -971,7 +966,7 @@ e->components = 1; e->format = EXIF_FORMAT_RATIONAL; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); r.numerator = 72; r.denominator = 1; exif_set_rational (e->data, o, r); @@ -982,8 +977,7 @@ e->components = 2; e->format = EXIF_FORMAT_RATIONAL; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); - if (e->data) memset (e->data, 0, e->size); + e->data = exif_entry_alloc (e, e->size); break; /* RATIONAL, 6 components */ @@ -991,7 +985,7 @@ e->components = 6; e->format = EXIF_FORMAT_RATIONAL; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; r.denominator = 1; r.numerator = 0; @@ -1022,7 +1016,7 @@ e->components = 20; e->format = EXIF_FORMAT_ASCII; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; snprintf ((char *) e->data, e->size, "%04i:%02i:%02i %02i:%02i:%02i", @@ -1047,7 +1041,7 @@ e->components = strlen ("[None]") + 1; e->format = EXIF_FORMAT_ASCII; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; strncpy (e->data, "[None]", e->size); break; @@ -1055,7 +1049,7 @@ e->components = (strlen ("[None]") + 1) * 2; e->format = EXIF_FORMAT_ASCII; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; strcpy (e->data + 0, "[None]"); strcpy (e->data + strlen ("[None]") + 1, "[None]"); @@ -1075,7 +1069,7 @@ e->components = 1; e->format = EXIF_FORMAT_UNDEFINED; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; e->data[0] = 0x01; break; @@ -1085,7 +1079,7 @@ e->components = 1; e->format = EXIF_FORMAT_UNDEFINED; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; e->data[0] = 0x03; break; @@ -1095,7 +1089,7 @@ e->components = 4; e->format = EXIF_FORMAT_UNDEFINED; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; memcpy (e->data, "0100", 4); break; @@ -1105,7 +1099,7 @@ e->components = 4; e->format = EXIF_FORMAT_UNDEFINED; e->size = exif_format_get_size (e->format) * e->components; - e->data = exif_entry_malloc (e, e->size); + e->data = exif_entry_alloc (e, e->size); if (!e->data) break; memcpy (e->data, "0210", 4); break; |