summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_write.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2006-11-10 06:39:46 +0000
committerkientzle <kientzle@FreeBSD.org>2006-11-10 06:39:46 +0000
commit50bb724108b7417b0df3bbf7029c43dbd734df49 (patch)
treef89881956f7ca553a6834444961e2cb90388cc29 /lib/libarchive/archive_write.c
parent56ac4302e20c910a87bfc933138eb38f4c21af7a (diff)
downloadFreeBSD-src-50bb724108b7417b0df3bbf7029c43dbd734df49.zip
FreeBSD-src-50bb724108b7417b0df3bbf7029c43dbd734df49.tar.gz
Portability and style fixes:
* Actually use the HAVE_<header>_H macros to conditionally include system headers. They've been defined for a long time, but only used in a few places. Now they're used pretty consistently throughout. * Fill in a lot of missing casts for conversions from void*. Although Standard C doesn't require this, some people have been trying to use C++ compilers with this code, and they do require it. Bit-for-bit, the compiled object files are identical, except for one assert() whose line number changed, so I'm pretty confident I didn't break anything. ;-)
Diffstat (limited to 'lib/libarchive/archive_write.c')
-rw-r--r--lib/libarchive/archive_write.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/libarchive/archive_write.c b/lib/libarchive/archive_write.c
index 72e49c0..148f6b5 100644
--- a/lib/libarchive/archive_write.c
+++ b/lib/libarchive/archive_write.c
@@ -35,13 +35,23 @@ __FBSDID("$FreeBSD$");
* needlessly bloating statically-linked clients.
*/
+#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
+#endif
+#ifdef HAVE_LIMITS_H
#include <limits.h>
+#endif
#include <stdio.h>
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
#include <time.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include "archive.h"
#include "archive_entry.h"
@@ -56,7 +66,7 @@ archive_write_new(void)
struct archive *a;
unsigned char *nulls;
- a = malloc(sizeof(*a));
+ a = (struct archive *)malloc(sizeof(*a));
if (a == NULL)
return (NULL);
memset(a, 0, sizeof(*a));
@@ -69,7 +79,7 @@ archive_write_new(void)
/* Initialize a block of nulls for padding purposes. */
a->null_length = 1024;
- nulls = malloc(a->null_length);
+ nulls = (unsigned char *)malloc(a->null_length);
if (nulls == NULL) {
free(a);
return (NULL);
OpenPOWER on IntegriCloud