summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Meissner <wmeissner@gmail.com>2009-12-12 09:13:38 +1000
committerWayne Meissner <wmeissner@gmail.com>2009-12-12 09:13:38 +1000
commit454220efb82988b01c4c2738e8fb2f53e303dbf3 (patch)
tree7836611becf0ec7eec318cd3bdaabc7cf955beb4
parent6be965409223ee3e32c1665cc7c02e2c3fea72a3 (diff)
downloadffi-454220efb82988b01c4c2738e8fb2f53e303dbf3.tar.gz
Use xfree when the memory comes from xmalloc/xcalloc/ALLOC_N
-rw-r--r--ext/ffi_c/Buffer.c2
-rw-r--r--ext/ffi_c/MemoryPointer.c4
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;