#include "fitz_base.h"

void * fz_malloc(int n)
{
    void *p = malloc(n);
    if (!p)
	fz_throw("cannot malloc %d bytes", n);
    return p;
}

void * fz_realloc(void *p, int n)
{
    void *np = realloc(p, n);
    if (np == nil)
	fz_throw("cannot realloc %d bytes", n);
    return np;
}

void fz_free(void *p)
{
    free(p);
}

char * fz_strdup(char *s)
{
    char *ns = strdup(s);
    if (!ns)
	fz_throw("cannot strdup %lu bytes", (unsigned long)strlen(s) + 1);
    return ns;
}


#include "fitz_base.h"

void * fz_malloc(int n)
{
    void *p = malloc(n);
    if (!p)
	fz_throw("cannot malloc %d bytes", n);
    return p;
}

void * fz_realloc(void *p, int n)
{
    void *np = realloc(p, n);
    if (np == nil)
	fz_throw("cannot realloc %d bytes", n);
    return np;
}

void fz_free(void *p)
{
    free(p);
}

char * fz_strdup(char *s)
{
    char *ns = strdup(s);
    if (!ns)
	fz_throw("cannot strdup %d bytes", strlen(s) + 1);
    return ns;
}


--- 
+++ 
@@ -25,7 +25,7 @@
 {
     char *ns = strdup(s);
     if (!ns)
-	fz_throw("cannot strdup %d bytes", strlen(s) + 1);
+	fz_throw("cannot strdup %lu bytes", (unsigned long)strlen(s) + 1);
     return ns;
 }
 
Use the correct format specifier for size_t in fz_strdup.

Prior to this patch, if the strdup failed, it would throw an error
printing the number of bytes that could not be allocated. However,
this was formatted as an int, while the actual argument passed is
the return value of strdup itself, which is usually a size_t.

This patch formats instead as an unsigned long, and adds a cast to
ensure the types match even on platforms where this isn't already
the case.
