From owner-p4-projects@FreeBSD.ORG Sat Jun 5 06:17:11 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 00433106566C; Sat, 5 Jun 2010 06:17:10 +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 AA24B1065677 for ; Sat, 5 Jun 2010 06:17:10 +0000 (UTC) (envelope-from jlaffaye@FreeBSD.org) Received: from repoman.freebsd.org (unknown [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7DF0C8FC14 for ; Sat, 5 Jun 2010 06:17:10 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o556HAum019325 for ; Sat, 5 Jun 2010 06:17:10 GMT (envelope-from jlaffaye@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o556HA8L019323 for perforce@freebsd.org; Sat, 5 Jun 2010 06:17:10 GMT (envelope-from jlaffaye@FreeBSD.org) Date: Sat, 5 Jun 2010 06:17:10 GMT Message-Id: <201006050617.o556HA8L019323@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jlaffaye@FreeBSD.org using -f From: Julien Laffaye To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 179200 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2010 06:17:11 -0000 http://p4web.freebsd.org/@@179200?ac=10 Change 179200 by jlaffaye@jlaffaye-chulak on 2010/06/05 06:16:29 Changed the prototype of unpack_to_buffer() It is more useful now as we know the size of the buffer. Affected files ... .. //depot/projects/soc2010/pkg_complete/lib/libpkg/file.c#4 edit .. //depot/projects/soc2010/pkg_complete/lib/libpkg/pkg.h#5 edit Differences ... ==== //depot/projects/soc2010/pkg_complete/lib/libpkg/file.c#4 (text+ko) ==== @@ -335,20 +335,18 @@ * Unpack a single file, denoted by file, to a buffer. It proceeds to read it * into the buffer which will need to be freed by the user at a later date. * - * Returns an address to a buffer with the contents of *file if successful, or - * returns NULL on failure. + * Returns the size of the buffer if successful, or returns 0 on failure. */ -char* -unpack_to_buffer(const char *pkg, const char *file) +size_t +unpack_to_buffer(const char *pkg, const char *file, char **buf) { struct archive *archive; struct archive_entry *archive_entry; Boolean found_match = FALSE; - int64_t buf_size; + size_t buf_size = 0; - char *buf = NULL; const char *entry_pathname = NULL; const char *error = NULL; int archive_fd = -1; @@ -403,17 +401,20 @@ errno = EINVAL; else { - buf = malloc(sizeof(char)*buf_size); + *buf = malloc(sizeof(char)*buf_size); - if (buf == NULL) + if (*buf == NULL) { error = strerror(errno); - else { + buf_size = 0; + } else { r = archive_read_data(archive, - buf, buf_size); + *buf, buf_size); - if (r != ARCHIVE_OK) + if (r != ARCHIVE_OK) { error = archive_error_string(archive); + buf_size = 0; + } } @@ -435,7 +436,7 @@ if (archive != NULL) archive_read_finish(archive); - return (buf); + return (buf_size); } ==== //depot/projects/soc2010/pkg_complete/lib/libpkg/pkg.h#5 (text+ko) ==== @@ -178,7 +178,7 @@ ssize_t write_file(const char *, const char *); int move_file(const char *, const char *, const char *); int delete_hierarchy(const char *, Boolean, Boolean); -char* unpack_to_buffer(const char *, const char *); +size_t unpack_to_buffer(const char *, const char *, char **); int unpack_to_disk(const char *, const char *); int unpack_to_fd(const char *, const char *); void format_cmd(char *, int, const char *, const char *,