diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-16 16:26:48 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-16 16:26:48 +0000 |
commit | 09a016ee7c5c81580b27db3bd193b38cb3bd4f0e (patch) | |
tree | 90d0fad103f7aa592451f493a3d091ca9db7c866 /fitz/fitz.h | |
parent | 1f8cccdeca9cf9082061b40d66fc8201c8b3ce80 (diff) | |
download | mupdf-09a016ee7c5c81580b27db3bd193b38cb3bd4f0e.tar.xz |
Add fz_malloc_struct, and make code use it.
The new fz_malloc_struct(A,B) macro allocates sizeof(B) bytes using
fz_malloc, and then passes the resultant pointer to Memento_label
to label it with "B".
This costs nothing in non-memento builds, but gives much nicer
listings of leaked blocks when memento is enabled.
Diffstat (limited to 'fitz/fitz.h')
-rw-r--r-- | fitz/fitz.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 4989b22f..b4c3cd15 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -189,6 +189,9 @@ void *fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size) void *fz_resize_array_no_throw(fz_context *ctx, void *p, unsigned int count, unsigned int size); char *fz_strdup_no_throw(fz_context *ctx, char *s); +#define fz_malloc_struct(CTX, STRUCT) \ + Memento_label(fz_malloc(CTX,sizeof(STRUCT)), #STRUCT) + /* runtime (hah!) test for endian-ness */ int fz_is_big_endian(void); |