PERFORCE change 145388 for review
Anselm Strauss
strauss at FreeBSD.org
Thu Jul 17 19:59:22 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145388
Change 145388 by strauss at strauss_marvelman on 2008/07/17 19:58:50
Read over the code, made some small fixes
Affected files ...
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#10 edit
Differences ...
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#10 (text+ko) ====
@@ -97,20 +97,14 @@
archive_write_set_format_zip(struct archive *_a)
{
struct archive_write *a = (struct archive_write *)_a;
- struct zip *zip;
+ struct zip zip;
/* If another format was already registered, unregister it. */
if (a->format_destroy != NULL)
(a->format_destroy)(a);
- zip = (struct zip *)malloc(sizeof(*zip));
- if (zip == NULL) {
- archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data");
- return (ARCHIVE_FATAL);
- }
- memset(zip, 0, sizeof(*zip));
zip->central_directory = NULL; /* To be sure. */
- a->format_data = zip;
+ a->format_data = &zip;
a->pad_uncompressed = 0; /* Actually not needed for now, since no compression support yet. */
a->format_write_header = archive_write_zip_header;
@@ -123,8 +117,8 @@
encode(
ZIP_SIGNATURE_DATA_DESCRIPTOR,
- &zip->data_descriptor.signature,
- sizeof(zip->data_descriptor.signature)
+ &zip.data_descriptor.signature,
+ sizeof(zip.data_descriptor.signature)
);
return (ARCHIVE_OK);
@@ -146,8 +140,6 @@
zip = (struct zip *) a->format_data;
d = (struct zip_data_descriptor *) &zip->data_descriptor;
ret = 0;
-
- memset(&h, 0, sizeof(h));
encode(ZIP_SIGNATURE_LOCAL_FILE_HEADER, &h.version, sizeof(h.version));
@@ -219,7 +211,7 @@
struct zip *zip = (struct zip *) a->format_data;
struct zip_data_descriptor *d = (struct zip_data_descriptor *) &zip->data_descriptor;
- ret = (a->compressor.write)(a, d, sizeof(d));
+ ret = (a->compressor.write)(a, d, sizeof(*d));
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
More information about the p4-projects
mailing list