3 /* Make this thread local storage if you wish. */
5 static void *stdmalloc(fz_memorycontext
*mem
, int n
)
10 fprintf(stderr
, "failed to malloc %d bytes\n", n
);
17 static void *stdrealloc(fz_memorycontext
*mem
, void *p
, int n
)
20 void *np
= realloc(p
, n
);
22 fprintf(stderr
, "realloc failed %d nytes", n
);
24 fprintf(stderr
, "realloc kept %d\n", n
);
26 fprintf(stderr
, "realloc moved %d\n", n
);
33 static void stdfree(fz_memorycontext
*mem
, void *p
)
38 static fz_memorycontext defmem
= { stdmalloc
, stdrealloc
, stdfree
};
39 static fz_memorycontext
*curmem
= &defmem
;
41 fz_error fz_koutofmem
= {
50 fz_currentmemorycontext()
56 fz_setmemorycontext(fz_memorycontext
*mem
)
64 fz_memorycontext
*mem
= fz_currentmemorycontext();
65 return mem
->malloc(mem
, n
);
69 fz_realloc(void *p
, int n
)
71 fz_memorycontext
*mem
= fz_currentmemorycontext();
72 return mem
->realloc(mem
, p
, n
);
78 fz_memorycontext
*mem
= fz_currentmemorycontext();
86 char *ns
= fz_malloc(len
+ 1);