From owner-p4-projects@FreeBSD.ORG Thu Jul 17 19:59:22 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A502D1065671; Thu, 17 Jul 2008 19:59:22 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 692291065672 for ; Thu, 17 Jul 2008 19:59:22 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5013A8FC16 for ; Thu, 17 Jul 2008 19:59:22 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m6HJxMUs017995 for ; Thu, 17 Jul 2008 19:59:22 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6HJxMIq017993 for perforce@freebsd.org; Thu, 17 Jul 2008 19:59:22 GMT (envelope-from strauss@FreeBSD.org) Date: Thu, 17 Jul 2008 19:59:22 GMT Message-Id: <200807171959.m6HJxMIq017993@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to strauss@FreeBSD.org using -f From: Anselm Strauss To: Perforce Change Reviews Cc: Subject: PERFORCE change 145388 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2008 19:59:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=145388 Change 145388 by strauss@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);