From: J?rg H. <ho...@us...> - 2004-05-15 20:29:27
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4043 Modified Files: exif-data.c Log Message: we know how much memory we need so we don't need to call realloc() all the time Index: exif-data.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-data.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- exif-data.c 13 May 2004 13:58:23 -0000 1.40 +++ exif-data.c 15 May 2004 20:29:19 -0000 1.41 @@ -701,19 +701,15 @@ void exif_data_save_data (ExifData *data, unsigned char **d, unsigned int *ds) { - if (!data) - return; - if (!d || !ds) + if (!data || !d || !ds) return; /* Header */ - *ds = 6; - *d = malloc (sizeof (char) * *ds); + *ds = 14; + *d = malloc (*ds); memcpy (*d, ExifHeader, 6); /* Order (offset 6) */ - *ds += 2; - *d = realloc (*d, sizeof (char) * *ds); if (data->priv->order == EXIF_BYTE_ORDER_INTEL) { memcpy (*d + 6, "II", 2); } else { @@ -721,8 +717,6 @@ } /* Fixed value (2 bytes, offset 8) */ - *ds += 2; - *d = realloc (*d, sizeof (char) * *ds); exif_set_short (*d + 8, data->priv->order, 0x002a); /* @@ -731,8 +725,6 @@ * EXIF header (2 bytes for order, another 2 for the test, and * 4 bytes for the IFD 0 offset make 8 bytes together). */ - *ds += 4; - *d = realloc (*d, sizeof (char) * *ds); exif_set_long (*d + 10, data->priv->order, 8); /* Now save IFD 0. IFD 1 will be saved automatically. */ |