#include <iconv.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <assert.h>
#ifdef HAVE_ENDIAN_H
#include <endian.h>
#endif
#define be64toh(x) __bswap_64 (x)
#endif
#ifndef le16toh
-#define le32toh(x) (x)
+#define le16toh(x) (x)
#endif
#ifndef le32toh
#define le32toh(x) (x)
#endif
#ifndef le64toh
-#define le32toh(x) (x)
+#define le64toh(x) (x)
#endif
#else
#ifndef be32toh
}
h->bitmap = calloc (1 + h->size / 32, 1);
+ if (h->bitmap == NULL)
+ goto error;
#if 0 /* Doesn't work. */
/* Header checksum. */
size_t r = iconv (ic, &inp, &inlen, &outp, &outlen);
if (r == (size_t) -1) {
if (errno == E2BIG) {
+ size_t prev = outalloc;
/* Try again with a larger output buffer. */
free (out);
outalloc *= 2;
+ if (outalloc < prev)
+ return NULL;
goto again;
}
else {