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)
{
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);
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 */
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;
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;
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;
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;
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 (
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 (
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 */
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 */
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);
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 */
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;
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",
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;
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]");
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;
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;
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;
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;