diff options
author | Wayne Meissner <wmeissner@gmail.com> | 2009-12-12 09:13:38 +1000 |
---|---|---|
committer | Wayne Meissner <wmeissner@gmail.com> | 2009-12-12 09:13:38 +1000 |
commit | 454220efb82988b01c4c2738e8fb2f53e303dbf3 (patch) | |
tree | 7836611becf0ec7eec318cd3bdaabc7cf955beb4 | |
parent | 6be965409223ee3e32c1665cc7c02e2c3fea72a3 (diff) | |
download | ffi-454220efb82988b01c4c2738e8fb2f53e303dbf3.tar.gz |
Use xfree when the memory comes from xmalloc/xcalloc/ALLOC_N
-rw-r--r-- | ext/ffi_c/Buffer.c | 2 | ||||
-rw-r--r-- | ext/ffi_c/MemoryPointer.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/ext/ffi_c/Buffer.c b/ext/ffi_c/Buffer.c index 5755b0a..96c0cc1 100644 --- a/ext/ffi_c/Buffer.c +++ b/ext/ffi_c/Buffer.c @@ -151,7 +151,7 @@ buffer_free(VALUE self) Data_Get_Struct(self, Buffer, ptr); if (ptr->storage != NULL) { - free(ptr->storage); + xfree(ptr->storage); ptr->storage = NULL; } diff --git a/ext/ffi_c/MemoryPointer.c b/ext/ffi_c/MemoryPointer.c index 9d0e632..87cebbb 100644 --- a/ext/ffi_c/MemoryPointer.c +++ b/ext/ffi_c/MemoryPointer.c @@ -105,7 +105,7 @@ memptr_malloc(VALUE self, long size, long count, bool clear) /* ensure the memory is aligned on at least a 8 byte boundary */ p->memory.address = (char *) (((uintptr_t) p->storage + 0x7) & (uintptr_t) ~0x7UL);; p->allocated = true; - + if (clear && p->memory.size > 0) { memset(p->memory.address, 0, p->memory.size); } @@ -134,7 +134,7 @@ memptr_free(VALUE self) if (ptr->allocated) { if (ptr->storage != NULL) { - free(ptr->storage); + xfree(ptr->storage); ptr->storage = NULL; } ptr->allocated = false; |