Author: brucem
Date: Sun May 23 09:06:55 2010
New Revision: 947385
URL: http://svn.apache.org/viewvc?rev=947385&view=rev
Log:
AVRO-549: Route memory management through an allocator interface.
Added:
avro/trunk/lang/c/src/allocator.c
avro/trunk/lang/c/src/allocator.h
avro/trunk/lang/c/src/allocator_system.c
avro/trunk/lang/c/src/allocator_system.h
Modified:
avro/trunk/lang/c/src/CMakeLists.txt
avro/trunk/lang/c/src/atom_table.c
avro/trunk/lang/c/src/avro.c
avro/trunk/lang/c/src/datafile.c
avro/trunk/lang/c/src/datum.c
avro/trunk/lang/c/src/datum_read.c
avro/trunk/lang/c/src/encoding_binary.c
avro/trunk/lang/c/src/io.c
avro/trunk/lang/c/src/schema.c
avro/trunk/lang/c/src/st.c
Modified: avro/trunk/lang/c/src/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/CMakeLists.txt?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/CMakeLists.txt (original)
+++ avro/trunk/lang/c/src/CMakeLists.txt Sun May 23 09:06:55 2010
@@ -18,6 +18,10 @@
#
set(AVRO_SRC
+ allocator.c
+ allocator.h
+ allocator_system.c
+ allocator_system.h
atom_table.c
avro.c
avro.h
Added: avro/trunk/lang/c/src/allocator.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/allocator.c?rev=947385&view=auto
==============================================================================
--- avro/trunk/lang/c/src/allocator.c (added)
+++ avro/trunk/lang/c/src/allocator.c Sun May 23 09:06:55 2010
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to you under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+* implied. See the License for the specific language governing
+* permissions and limitations under the License.
+*/
+
+#include "allocator.h"
+#include <string.h>
+
+struct avro_allocator_t_ g_avro_allocator = {
+ NULL, // malloc
+ NULL, // calloc
+ NULL, // realloc
+ NULL // free
+};
+
+char*
+avro_strdup(const char* source)
+{
+ char* dest = (char*)g_avro_allocator.malloc(strlen(source) + 1);
+ strcpy(dest, source);
+ return dest;
+}
Added: avro/trunk/lang/c/src/allocator.h
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/allocator.h?rev=947385&view=auto
==============================================================================
--- avro/trunk/lang/c/src/allocator.h (added)
+++ avro/trunk/lang/c/src/allocator.h Sun May 23 09:06:55 2010
@@ -0,0 +1,39 @@
+#ifndef AVRO_ALLOCATOR_H
+#define AVRO_ALLOCATOR_H
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to you under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+* implied. See the License for the specific language governing
+* permissions and limitations under the License.
+*/
+
+#include <stddef.h>
+
+typedef void * (*avro_malloc_def)(size_t size);
+typedef void * (*avro_calloc_def)(size_t count, size_t size);
+typedef void * (*avro_realloc_def)(void *ptr, size_t size);
+typedef void (*avro_free_def)(void *ptr);
+
+struct avro_allocator_t_
+{
+ avro_malloc_def malloc;
+ avro_calloc_def calloc;
+ avro_realloc_def realloc;
+ avro_free_def free;
+};
+
+extern struct avro_allocator_t_ g_avro_allocator;
+
+char* avro_strdup(const char* source);
+
+#endif // AVRO_ALLOCATOR_H
Added: avro/trunk/lang/c/src/allocator_system.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/allocator_system.c?rev=947385&view=auto
==============================================================================
--- avro/trunk/lang/c/src/allocator_system.c (added)
+++ avro/trunk/lang/c/src/allocator_system.c Sun May 23 09:06:55 2010
@@ -0,0 +1,70 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to you under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+* implied. See the License for the specific language governing
+* permissions and limitations under the License.
+*/
+
+#include "allocator_system.h"
+#include "allocator.h"
+
+#include <stdlib.h>
+
+//------------------------------------------------------------------------------
+/**
+*/
+void
+avro_allocator_system_initialize(void)
+{
+ g_avro_allocator.malloc = avro_allocator_system_malloc;
+ g_avro_allocator.calloc = avro_allocator_system_calloc;
+ g_avro_allocator.realloc = avro_allocator_system_realloc;
+ g_avro_allocator.free = avro_allocator_system_free;
+}
+
+//------------------------------------------------------------------------------
+/**
+*/
+void*
+avro_allocator_system_malloc(size_t size)
+{
+ return malloc(size);
+}
+
+//------------------------------------------------------------------------------
+/**
+*/
+void*
+avro_allocator_system_calloc(size_t count, size_t size)
+{
+ return calloc(count, size);
+}
+
+//------------------------------------------------------------------------------
+/**
+*/
+void*
+avro_allocator_system_realloc(void *ptr, size_t size)
+{
+ return realloc(ptr, size);
+}
+
+//------------------------------------------------------------------------------
+/**
+*/
+void
+avro_allocator_system_free(void *ptr)
+{
+ free(ptr);
+}
+
Added: avro/trunk/lang/c/src/allocator_system.h
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/allocator_system.h?rev=947385&view=auto
==============================================================================
--- avro/trunk/lang/c/src/allocator_system.h (added)
+++ avro/trunk/lang/c/src/allocator_system.h Sun May 23 09:06:55 2010
@@ -0,0 +1,28 @@
+#ifndef AVRO_ALLOCATOR_SYSTEM_H
+#define AVRO_ALLOCATOR_SYSTEM_H
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to you under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+* implied. See the License for the specific language governing
+* permissions and limitations under the License.
+*/
+
+#include <stddef.h>
+
+void avro_allocator_system_initialize(void);
+void* avro_allocator_system_malloc(size_t size);
+void* avro_allocator_system_calloc(size_t count, size_t size);
+void* avro_allocator_system_realloc(void *ptr, size_t size);
+void avro_allocator_system_free(void *ptr);
+
+#endif // AVRO_ALLOCATOR_SYSTEM_H
Modified: avro/trunk/lang/c/src/atom_table.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/atom_table.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/atom_table.c (original)
+++ avro/trunk/lang/c/src/atom_table.c Sun May 23 09:06:55 2010
@@ -16,7 +16,7 @@
*/
#include "avro_private.h"
-
+#include "allocator.h"
#include <stdlib.h>
#include <string.h>
@@ -61,11 +61,11 @@ avro_atom_table_t avro_atom_table_create
avro_atom_table_t table;
int32_t i;
- table = (avro_atom_table_t)malloc(sizeof(struct avro_atom_table_t_));
+ table = (avro_atom_table_t)g_avro_allocator.malloc(sizeof(struct
avro_atom_table_t_));
table->size = size;
table->count = 0;
- table->entries = malloc(sizeof(avro_atom_entry_t) * table->size);
- table->hashtab = malloc(sizeof(int32_t) * table->size);
+ table->entries = g_avro_allocator.malloc(sizeof(avro_atom_entry_t) *
table->size);
+ table->hashtab = g_avro_allocator.malloc(sizeof(int32_t) * table->size);
table->freelist = 0;
memset(table->entries, 0, sizeof(avro_atom_entry_t) * table->size);
@@ -85,12 +85,12 @@ void avro_atom_table_destroy(avro_atom_t
int32_t i;
for (i = 0; i < table->size; i++) {
if (table->entries[i].str) {
- free(table->entries[i].str);
+ g_avro_allocator.free(table->entries[i].str);
}
}
- free(table->entries);
- free(table->hashtab);
- free(table);
+ g_avro_allocator.free(table->entries);
+ g_avro_allocator.free(table->hashtab);
+ g_avro_allocator.free(table);
}
void avro_atom_table_dump(avro_atom_table_t table)
@@ -141,8 +141,8 @@ avro_atom_t avro_atom_table_add_length(a
new_size = table->size * 2;
}
- table->entries = realloc(table->entries,
sizeof(avro_atom_entry_t) * new_size);
- table->hashtab = realloc(table->hashtab, sizeof(int32_t) *
new_size);
+ table->entries = g_avro_allocator.realloc(table->entries,
sizeof(avro_atom_entry_t) * new_size);
+ table->hashtab = g_avro_allocator.realloc(table->hashtab,
sizeof(int32_t) * new_size);
/* Make new string of freelist. */
memset(&(table->entries[table->size]), 0,
sizeof(avro_atom_entry_t) * (new_size-table->size));
@@ -169,7 +169,7 @@ avro_atom_t avro_atom_table_add_length(a
atom = table->freelist;
entry = &(table->entries[atom]);
table->freelist = entry->next;
- entry->str = strdup(str);
+ entry->str = avro_strdup(str);
entry->length = length;
entry->refcount = 1;
entry->hash_value = hash_value;
@@ -235,7 +235,7 @@ void avro_atom_table_decref(avro_atom_ta
bucket = _atom_string_hash(table->entries[atom].str) %
table->size;
/* Free the string. */
- free(table->entries[atom].str);
+ g_avro_allocator.free(table->entries[atom].str);
table->entries[atom].str = NULL;
table->entries[atom].length = 0;
table->entries[atom].hash_value = 0;
Modified: avro/trunk/lang/c/src/avro.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro.c (original)
+++ avro/trunk/lang/c/src/avro.c Sun May 23 09:06:55 2010
@@ -16,12 +16,15 @@
*/
#include "avro_private.h"
+#include "allocator_system.h"
// TODO: Make these configurable in the future somehow
#define INITIAL_ATOM_TABLE_SIZE 512
void avro_init(void)
{
+ avro_allocator_system_initialize();
+
if (NULL == g_avro_atom_table) {
g_avro_atom_table =
avro_atom_table_create(INITIAL_ATOM_TABLE_SIZE);
}
Modified: avro/trunk/lang/c/src/datafile.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datafile.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datafile.c (original)
+++ avro/trunk/lang/c/src/datafile.c Sun May 23 09:06:55 2010
@@ -17,6 +17,7 @@
#include "avro_private.h"
#include "encoding.h"
+#include "allocator.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -133,13 +134,13 @@ avro_file_writer_create(const char *path
if (!path || !is_avro_schema(schema) || !writer) {
return EINVAL;
}
- w = malloc(sizeof(struct avro_file_writer_t_));
+ w = g_avro_allocator.malloc(sizeof(struct avro_file_writer_t_));
if (!w) {
return ENOMEM;
}
rval = file_writer_create(path, schema, w);
if (rval) {
- free(w);
+ g_avro_allocator.free(w);
return rval;
}
*writer = w;
@@ -200,7 +201,7 @@ static int file_writer_open(const char *
/* Position to end of file and get ready to write */
rval = file_writer_init_fp(path, "a", w);
if (rval) {
- free(w);
+ g_avro_allocator.free(w);
}
return rval;
}
@@ -212,13 +213,13 @@ int avro_file_writer_open(const char *pa
if (!path || !writer) {
return EINVAL;
}
- w = malloc(sizeof(struct avro_file_writer_t_));
+ w = g_avro_allocator.malloc(sizeof(struct avro_file_writer_t_));
if (!w) {
return ENOMEM;
}
rval = file_writer_open(path, w);
if (rval) {
- free(w);
+ g_avro_allocator.free(w);
return rval;
}
@@ -240,7 +241,7 @@ int avro_file_reader(const char *path, a
{
int rval;
FILE *fp;
- avro_file_reader_t r = malloc(sizeof(struct avro_file_reader_t_));
+ avro_file_reader_t r = g_avro_allocator.malloc(sizeof(struct
avro_file_reader_t_));
if (!r) {
return ENOMEM;
}
Modified: avro/trunk/lang/c/src/datum.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.c (original)
+++ avro/trunk/lang/c/src/datum.c Sun May 23 09:06:55 2010
@@ -21,6 +21,7 @@
#include <errno.h>
#include "datum.h"
#include "encoding.h"
+#include "allocator.h"
#define DEFAULT_ARRAY_SIZE 10
#define DEFAULT_FIELD_COUNT 10
@@ -37,7 +38,7 @@ static avro_datum_t avro_string_private(
void (*string_free) (void *ptr))
{
struct avro_string_datum_t *datum =
- malloc(sizeof(struct avro_string_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_string_datum_t));
if (!datum) {
return NULL;
}
@@ -50,16 +51,16 @@ static avro_datum_t avro_string_private(
avro_datum_t avro_string(const char *str)
{
- char *p = strdup(str);
+ char *p = avro_strdup(str);
if (!p) {
return NULL;
}
- return avro_string_private(p, free);
+ return avro_string_private(p, g_avro_allocator.free);
}
avro_datum_t avro_givestring(const char *str)
{
- return avro_string_private((char *)str, free);
+ return avro_string_private((char *)str, g_avro_allocator.free);
}
avro_datum_t avro_wrapstring(const char *str)
@@ -94,21 +95,21 @@ static int avro_string_set_private(avro_
int avro_string_set(avro_datum_t datum, const char *p)
{
- char *string_copy = strdup(p);
+ char *string_copy = avro_strdup(p);
int rval;
if (!string_copy) {
return ENOMEM;
}
- rval = avro_string_set_private(datum, p, free);
+ rval = avro_string_set_private(datum, p, g_avro_allocator.free);
if (rval) {
- free(string_copy);
+ g_avro_allocator.free(string_copy);
}
return rval;
}
int avro_givestring_set(avro_datum_t datum, const char *p)
{
- return avro_string_set_private(datum, p, free);
+ return avro_string_set_private(datum, p, g_avro_allocator.free);
}
int avro_wrapstring_set(avro_datum_t datum, const char *p)
@@ -120,7 +121,7 @@ static avro_datum_t avro_bytes_private(c
void (*bytes_free) (void *ptr))
{
struct avro_bytes_datum_t *datum;
- datum = malloc(sizeof(struct avro_bytes_datum_t));
+ datum = g_avro_allocator.malloc(sizeof(struct avro_bytes_datum_t));
if (!datum) {
return NULL;
}
@@ -134,17 +135,17 @@ static avro_datum_t avro_bytes_private(c
avro_datum_t avro_bytes(const char *bytes, int64_t size)
{
- char *bytes_copy = malloc(size);
+ char *bytes_copy = g_avro_allocator.malloc(size);
if (!bytes_copy) {
return NULL;
}
memcpy(bytes_copy, bytes, size);
- return avro_bytes_private(bytes_copy, size, free);
+ return avro_bytes_private(bytes_copy, size, g_avro_allocator.free);
}
avro_datum_t avro_givebytes(const char *bytes, int64_t size)
{
- return avro_bytes_private((char *)bytes, size, free);
+ return avro_bytes_private((char *)bytes, size, g_avro_allocator.free);
}
avro_datum_t avro_wrapbytes(const char *bytes, int64_t size)
@@ -177,14 +178,14 @@ static int avro_bytes_set_private(avro_d
int avro_bytes_set(avro_datum_t datum, const char *bytes, const int64_t size)
{
int rval;
- char *bytes_copy = malloc(size);
+ char *bytes_copy = g_avro_allocator.malloc(size);
if (!bytes_copy) {
return ENOMEM;
}
memcpy(bytes_copy, bytes, size);
- rval = avro_bytes_set_private(datum, bytes, size, free);
+ rval = avro_bytes_set_private(datum, bytes, size,
g_avro_allocator.free);
if (rval) {
- free(bytes_copy);
+ g_avro_allocator.free(bytes_copy);
}
return rval;
}
@@ -192,7 +193,7 @@ int avro_bytes_set(avro_datum_t datum, c
int avro_givebytes_set(avro_datum_t datum, const char *bytes,
const int64_t size)
{
- return avro_bytes_set_private(datum, bytes, size, free);
+ return avro_bytes_set_private(datum, bytes, size,
g_avro_allocator.free);
}
int avro_wrapbytes_set(avro_datum_t datum, const char *bytes,
@@ -214,7 +215,7 @@ int avro_bytes_get(avro_datum_t datum, c
avro_datum_t avro_int32(int32_t i)
{
struct avro_int32_datum_t *datum =
- malloc(sizeof(struct avro_int32_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_int32_datum_t));
if (!datum) {
return NULL;
}
@@ -247,7 +248,7 @@ int avro_int32_set(avro_datum_t datum, c
avro_datum_t avro_int64(int64_t l)
{
struct avro_int64_datum_t *datum =
- malloc(sizeof(struct avro_int64_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_int64_datum_t));
if (!datum) {
return NULL;
}
@@ -280,7 +281,7 @@ int avro_int64_set(avro_datum_t datum, c
avro_datum_t avro_float(float f)
{
struct avro_float_datum_t *datum =
- malloc(sizeof(struct avro_float_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_float_datum_t));
if (!datum) {
return NULL;
}
@@ -313,7 +314,7 @@ int avro_float_get(avro_datum_t datum, f
avro_datum_t avro_double(double d)
{
struct avro_double_datum_t *datum =
- malloc(sizeof(struct avro_double_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_double_datum_t));
if (!datum) {
return NULL;
}
@@ -346,7 +347,7 @@ int avro_double_get(avro_datum_t datum,
avro_datum_t avro_boolean(int8_t i)
{
struct avro_boolean_datum_t *datum =
- malloc(sizeof(struct avro_boolean_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_boolean_datum_t));
if (!datum) {
return NULL;
}
@@ -388,7 +389,7 @@ avro_datum_t avro_null(void)
avro_datum_t avro_union(int64_t discriminant, avro_datum_t value)
{
struct avro_union_datum_t *datum =
- malloc(sizeof(struct avro_union_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_union_datum_t));
if (!datum) {
return NULL;
}
@@ -402,39 +403,39 @@ avro_datum_t avro_union(int64_t discrimi
avro_datum_t avro_record(const char *name, const char *space)
{
struct avro_record_datum_t *datum =
- malloc(sizeof(struct avro_record_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_record_datum_t));
if (!datum) {
return NULL;
}
- datum->name = strdup(name);
+ datum->name = avro_strdup(name);
if (!datum->name) {
- free(datum);
+ g_avro_allocator.free(datum);
return NULL;
}
- datum->space = space ? strdup(space) : NULL;
+ datum->space = space ? avro_strdup(space) : NULL;
if (space && !datum->space) {
- free((void *)datum->name);
- free((void *)datum);
+ g_avro_allocator.free((void *)datum->name);
+ g_avro_allocator.free((void *)datum);
return NULL;
}
datum->alloc_fields = DEFAULT_FIELD_COUNT;
- datum->field_order = (avro_atom_t*)malloc(datum->alloc_fields *
sizeof(avro_atom_t));
+ datum->field_order =
(avro_atom_t*)g_avro_allocator.malloc(datum->alloc_fields *
sizeof(avro_atom_t));
if (!datum->field_order) {
if (space) {
- free((void *)datum->space);
+ g_avro_allocator.free((void *)datum->space);
}
- free((char *)datum->name);
- free(datum);
+ g_avro_allocator.free((char *)datum->name);
+ g_avro_allocator.free(datum);
return NULL;
}
datum->fields_byname = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!datum->fields_byname) {
- free(datum->field_order);
+ g_avro_allocator.free(datum->field_order);
if (space) {
- free((void *)datum->space);
+ g_avro_allocator.free((void *)datum->space);
}
- free((char *)datum->name);
- free(datum);
+ g_avro_allocator.free((char *)datum->name);
+ g_avro_allocator.free(datum);
return NULL;
}
datum->num_fields = 0;
@@ -477,7 +478,7 @@ avro_record_set(const avro_datum_t datum
avro_datum_to_record(datum);
if ((record->num_fields + 1) > record->alloc_fields) {
record->alloc_fields *= 2;
- record->field_order =
(avro_atom_t*)realloc(record->field_order,
+ record->field_order =
(avro_atom_t*)g_avro_allocator.realloc(record->field_order,
(record->alloc_fields) *
sizeof(avro_atom_t));
}
avro_atom_incref(field_name);
@@ -495,11 +496,11 @@ avro_record_set(const avro_datum_t datum
avro_datum_t avro_enum(const char *name, int i)
{
struct avro_enum_datum_t *datum =
- malloc(sizeof(struct avro_enum_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_enum_datum_t));
if (!datum) {
return NULL;
}
- datum->name = strdup(name);
+ datum->name = avro_strdup(name);
datum->value = i;
avro_datum_init(&datum->obj, AVRO_ENUM);
@@ -511,11 +512,11 @@ static avro_datum_t avro_fixed_private(c
void (*fixed_free) (void *ptr))
{
struct avro_fixed_datum_t *datum =
- malloc(sizeof(struct avro_fixed_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_fixed_datum_t));
if (!datum) {
return NULL;
}
- datum->name = strdup(name);
+ datum->name = avro_strdup(name);
datum->size = size;
datum->bytes = (char *)bytes;
datum->free = fixed_free;
@@ -526,12 +527,12 @@ static avro_datum_t avro_fixed_private(c
avro_datum_t avro_fixed(const char *name, const char *bytes, const int64_t
size)
{
- char *bytes_copy = malloc(size);
+ char *bytes_copy = g_avro_allocator.malloc(size);
if (!bytes_copy) {
return NULL;
}
memcpy(bytes_copy, bytes, size);
- return avro_fixed_private(name, bytes, size, free);
+ return avro_fixed_private(name, bytes, size, g_avro_allocator.free);
}
avro_datum_t avro_wrapfixed(const char *name, const char *bytes,
@@ -543,7 +544,7 @@ avro_datum_t avro_wrapfixed(const char *
avro_datum_t avro_givefixed(const char *name, const char *bytes,
const int64_t size)
{
- return avro_fixed_private(name, bytes, size, free);
+ return avro_fixed_private(name, bytes, size, g_avro_allocator.free);
}
static int avro_fixed_set_private(avro_datum_t datum, const char *bytes,
@@ -571,14 +572,14 @@ static int avro_fixed_set_private(avro_d
int avro_fixed_set(avro_datum_t datum, const char *bytes, const int64_t size)
{
int rval;
- char *bytes_copy = malloc(size);
+ char *bytes_copy = g_avro_allocator.malloc(size);
if (!bytes_copy) {
return ENOMEM;
}
memcpy(bytes_copy, bytes, size);
- rval = avro_fixed_set_private(datum, bytes, size, free);
+ rval = avro_fixed_set_private(datum, bytes, size,
g_avro_allocator.free);
if (rval) {
- free(bytes_copy);
+ g_avro_allocator.free(bytes_copy);
}
return rval;
}
@@ -586,7 +587,7 @@ int avro_fixed_set(avro_datum_t datum, c
int avro_givefixed_set(avro_datum_t datum, const char *bytes,
const int64_t size)
{
- return avro_fixed_set_private(datum, bytes, size, free);
+ return avro_fixed_set_private(datum, bytes, size,
g_avro_allocator.free);
}
int avro_wrapfixed_set(avro_datum_t datum, const char *bytes,
@@ -608,13 +609,13 @@ int avro_fixed_get(avro_datum_t datum, c
avro_datum_t avro_map(void)
{
struct avro_map_datum_t *datum =
- malloc(sizeof(struct avro_map_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_map_datum_t));
if (!datum) {
return NULL;
}
datum->map = st_init_strtable_with_size(DEFAULT_TABLE_SIZE);
if (!datum->map) {
- free(datum);
+ g_avro_allocator.free(datum);
return NULL;
}
@@ -660,7 +661,7 @@ avro_map_set(const avro_datum_t datum, c
avro_datum_decref(old_datum);
} else {
/* Inserting a new value */
- save_key = strdup(key);
+ save_key = avro_strdup(key);
if (!save_key) {
return ENOMEM;
}
@@ -674,14 +675,14 @@ avro_map_set(const avro_datum_t datum, c
avro_datum_t avro_array(void)
{
struct avro_array_datum_t *datum =
- malloc(sizeof(struct avro_array_datum_t));
+ g_avro_allocator.malloc(sizeof(struct avro_array_datum_t));
if (!datum) {
return NULL;
}
datum->alloc_els = DEFAULT_ARRAY_SIZE;
- datum->els = malloc(datum->alloc_els * sizeof(avro_datum_t));
+ datum->els = g_avro_allocator.malloc(datum->alloc_els *
sizeof(avro_datum_t));
if (!datum->els) {
- free(datum);
+ g_avro_allocator.free(datum);
return NULL;
}
datum->num_els = 0;
@@ -715,7 +716,7 @@ avro_array_append_datum(const avro_datum
array = avro_datum_to_array(array_datum);
if ((array->num_els + 1) > array->alloc_els) {
array->alloc_els *= 2;
- array->els = (avro_datum_t *)realloc(array->els,
+ array->els = (avro_datum_t
*)g_avro_allocator.realloc(array->els,
(array->alloc_els) * sizeof(avro_datum_t));
}
array->els[array->num_els++] = avro_datum_incref(datum);
@@ -736,7 +737,7 @@ static int char_datum_free_foreach(char
AVRO_UNUSED(arg);
avro_datum_decref(datum);
- free(key);
+ g_avro_allocator.free(key);
return ST_DELETE;
}
@@ -750,7 +751,7 @@ static void avro_datum_free(avro_datum_t
if (string->free) {
string->free(string->s);
}
- free(string);
+ g_avro_allocator.free(string);
}
break;
case AVRO_BYTES:{
@@ -759,37 +760,37 @@ static void avro_datum_free(avro_datum_t
if (bytes->free) {
bytes->free(bytes->bytes);
}
- free(bytes);
+ g_avro_allocator.free(bytes);
}
break;
case AVRO_INT32:{
struct avro_int32_datum_t *i;
i = avro_datum_to_int32(datum);
- free(i);
+ g_avro_allocator.free(i);
}
break;
case AVRO_INT64:{
struct avro_int64_datum_t *l;
l = avro_datum_to_int64(datum);
- free(l);
+ g_avro_allocator.free(l);
}
break;
case AVRO_FLOAT:{
struct avro_float_datum_t *f;
f = avro_datum_to_float(datum);
- free(f);
+ g_avro_allocator.free(f);
}
break;
case AVRO_DOUBLE:{
struct avro_double_datum_t *d;
d = avro_datum_to_double(datum);
- free(d);
+ g_avro_allocator.free(d);
}
break;
case AVRO_BOOLEAN:{
struct avro_boolean_datum_t *b;
b = avro_datum_to_boolean(datum);
- free(b);
+ g_avro_allocator.free(b);
}
break;
case AVRO_NULL:
@@ -800,35 +801,35 @@ static void avro_datum_free(avro_datum_t
int i;
struct avro_record_datum_t *record;
record = avro_datum_to_record(datum);
- free((void *)record->name);
+ g_avro_allocator.free((void *)record->name);
if (record->space) {
- free((void *)record->space);
+ g_avro_allocator.free((void
*)record->space);
}
st_foreach(record->fields_byname,
atom_datum_free_foreach, 0);
for (i = 0; i < record->num_fields; i++) {
avro_atom_decref(record->field_order[i]);
}
- free(record->field_order);
+ g_avro_allocator.free(record->field_order);
st_free_table(record->fields_byname);
- free(record);
+ g_avro_allocator.free(record);
}
break;
case AVRO_ENUM:{
struct avro_enum_datum_t *enump;
enump = avro_datum_to_enum(datum);
- free((void *)enump->name);
- free(enump);
+ g_avro_allocator.free((void *)enump->name);
+ g_avro_allocator.free(enump);
}
break;
case AVRO_FIXED:{
struct avro_fixed_datum_t *fixed;
fixed = avro_datum_to_fixed(datum);
- free((void *)fixed->name);
+ g_avro_allocator.free((void *)fixed->name);
if (fixed->free) {
fixed->free((void *)fixed->bytes);
}
- free(fixed);
+ g_avro_allocator.free(fixed);
}
break;
case AVRO_MAP:{
@@ -837,7 +838,7 @@ static void avro_datum_free(avro_datum_t
st_foreach(map->map, char_datum_free_foreach,
0);
st_free_table(map->map);
- free(map);
+ g_avro_allocator.free(map);
}
break;
case AVRO_ARRAY:{
@@ -847,15 +848,15 @@ static void avro_datum_free(avro_datum_t
for (i = 0; i < array->num_els; i++) {
avro_datum_decref(array->els[i]);
}
- free(array->els);
- free(array);
+ g_avro_allocator.free(array->els);
+ g_avro_allocator.free(array);
}
break;
case AVRO_UNION:{
struct avro_union_datum_t *unionp;
unionp = avro_datum_to_union(datum);
avro_datum_decref(unionp->value);
- free(unionp);
+ g_avro_allocator.free(unionp);
}
break;
case AVRO_LINK:{
Modified: avro/trunk/lang/c/src/datum_read.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_read.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_read.c (original)
+++ avro/trunk/lang/c/src/datum_read.c Sun May 23 09:06:55 2010
@@ -22,6 +22,7 @@
#include "encoding.h"
#include "schema.h"
#include "datum.h"
+#include "allocator.h"
int
avro_schema_match(avro_schema_t writers_schema, avro_schema_t readers_schema)
@@ -197,16 +198,16 @@ read_map(avro_reader_t reader, const avr
avro_schema_to_map(readers_schema)->
values, &value);
if (rval) {
- free(key);
+ g_avro_allocator.free(key);
return rval;
}
rval = avro_map_set(map, key, value);
if (rval) {
- free(key);
+ g_avro_allocator.free(key);
return rval;
}
avro_datum_decref(value);
- free(key);
+ g_avro_allocator.free(key);
}
rval = enc->read_long(reader, &block_count);
if (rval) {
@@ -392,7 +393,7 @@ avro_read_data(avro_reader_t reader, avr
int64_t size =
avro_schema_to_fixed(writers_schema)->size;
- bytes = malloc(size);
+ bytes = g_avro_allocator.malloc(size);
if (!bytes) {
return ENOMEM;
}
Modified: avro/trunk/lang/c/src/encoding_binary.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/encoding_binary.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/encoding_binary.c (original)
+++ avro/trunk/lang/c/src/encoding_binary.c Sun May 23 09:06:55 2010
@@ -16,6 +16,7 @@
*/
#include "avro_private.h"
+#include "allocator.h"
#include "encoding.h"
#include <stdlib.h>
#include <limits.h>
@@ -126,7 +127,7 @@ static int read_bytes(avro_reader_t read
if (rval) {
return rval;
}
- *bytes = malloc(*len + 1);
+ *bytes = g_avro_allocator.malloc(*len + 1);
if (!*bytes) {
return ENOMEM;
}
Modified: avro/trunk/lang/c/src/io.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/io.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/io.c (original)
+++ avro/trunk/lang/c/src/io.c Sun May 23 09:06:55 2010
@@ -21,6 +21,7 @@
#include <errno.h>
#include <string.h>
#include "dump.h"
+#include "allocator.h"
enum avro_io_type_t {
AVRO_FILE_IO,
@@ -89,7 +90,7 @@ static void writer_init(avro_writer_t wr
avro_reader_t avro_reader_file(FILE * fp)
{
struct _avro_reader_file_t *file_reader =
- malloc(sizeof(struct _avro_reader_file_t));
+ g_avro_allocator.malloc(sizeof(struct _avro_reader_file_t));
if (!file_reader) {
return NULL;
}
@@ -102,7 +103,7 @@ avro_reader_t avro_reader_file(FILE * fp
avro_writer_t avro_writer_file(FILE * fp)
{
struct _avro_writer_file_t *file_writer =
- malloc(sizeof(struct _avro_writer_file_t));
+ g_avro_allocator.malloc(sizeof(struct _avro_writer_file_t));
if (!file_writer) {
return NULL;
}
@@ -114,7 +115,7 @@ avro_writer_t avro_writer_file(FILE * fp
avro_reader_t avro_reader_memory(const char *buf, int64_t len)
{
struct _avro_reader_memory_t *mem_reader =
- malloc(sizeof(struct _avro_reader_memory_t));
+ g_avro_allocator.malloc(sizeof(struct _avro_reader_memory_t));
if (!mem_reader) {
return NULL;
}
@@ -128,7 +129,7 @@ avro_reader_t avro_reader_memory(const c
avro_writer_t avro_writer_memory(const char *buf, int64_t len)
{
struct _avro_writer_memory_t *mem_writer =
- malloc(sizeof(struct _avro_writer_memory_t));
+ g_avro_allocator.malloc(sizeof(struct _avro_writer_memory_t));
if (!mem_writer) {
return NULL;
}
@@ -346,19 +347,19 @@ void avro_reader_dump(avro_reader_t read
void avro_reader_free(avro_reader_t reader)
{
if (is_memory_io(reader)) {
- free(avro_reader_to_memory(reader));
+ g_avro_allocator.free(avro_reader_to_memory(reader));
} else if (is_file_io(reader)) {
fclose(avro_reader_to_file(reader)->fp);
- free(avro_reader_to_file(reader));
+ g_avro_allocator.free(avro_reader_to_file(reader));
}
}
void avro_writer_free(avro_writer_t writer)
{
if (is_memory_io(writer)) {
- free(avro_writer_to_memory(writer));
+ g_avro_allocator.free(avro_writer_to_memory(writer));
} else if (is_file_io(writer)) {
fclose(avro_writer_to_file(writer)->fp);
- free(avro_writer_to_file(writer));
+ g_avro_allocator.free(avro_writer_to_file(writer));
}
}
Modified: avro/trunk/lang/c/src/schema.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/schema.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/schema.c (original)
+++ avro/trunk/lang/c/src/schema.c Sun May 23 09:06:55 2010
@@ -25,6 +25,7 @@
#include "jansson.h"
#include "st.h"
#include "schema.h"
+#include "allocator.h"
#define DEFAULT_TABLE_SIZE 32
@@ -70,7 +71,7 @@ static int record_free_foreach(int i, st
avro_atom_decref(field->name);
avro_schema_decref(field->type);
- free(field);
+ g_avro_allocator.free(field);
return ST_DELETE;
}
@@ -79,7 +80,7 @@ static int enum_free_foreach(int i, char
AVRO_UNUSED(i);
AVRO_UNUSED(arg);
- free(sym);
+ g_avro_allocator.free(sym);
return ST_DELETE;
}
@@ -110,35 +111,35 @@ static void avro_schema_free(avro_schema
case AVRO_RECORD:{
struct avro_record_schema_t *record;
record = avro_schema_to_record(schema);
- free(record->name);
+ g_avro_allocator.free(record->name);
if (record->space) {
- free(record->space);
+ g_avro_allocator.free(record->space);
}
st_foreach(record->fields, record_free_foreach,
0);
st_free_table(record->fields_byname);
st_free_table(record->fields);
- free(record);
+ g_avro_allocator.free(record);
}
break;
case AVRO_ENUM:{
struct avro_enum_schema_t *enump;
enump = avro_schema_to_enum(schema);
- free(enump->name);
+ g_avro_allocator.free(enump->name);
st_foreach(enump->symbols, enum_free_foreach,
0);
st_free_table(enump->symbols);
st_free_table(enump->symbols_byname);
- free(enump);
+ g_avro_allocator.free(enump);
}
break;
case AVRO_FIXED:{
struct avro_fixed_schema_t *fixed;
fixed = avro_schema_to_fixed(schema);
- free((char *)fixed->name);
- free(fixed);
+ g_avro_allocator.free((char *)fixed->name);
+ g_avro_allocator.free(fixed);
}
break;
@@ -146,7 +147,7 @@ static void avro_schema_free(avro_schema
struct avro_map_schema_t *map;
map = avro_schema_to_map(schema);
avro_schema_decref(map->values);
- free(map);
+ g_avro_allocator.free(map);
}
break;
@@ -154,7 +155,7 @@ static void avro_schema_free(avro_schema
struct avro_array_schema_t *array;
array = avro_schema_to_array(schema);
avro_schema_decref(array->items);
- free(array);
+ g_avro_allocator.free(array);
}
break;
case AVRO_UNION:{
@@ -163,7 +164,7 @@ static void avro_schema_free(avro_schema
st_foreach(unionp->branches, union_free_foreach,
0);
st_free_table(unionp->branches);
- free(unionp);
+ g_avro_allocator.free(unionp);
}
break;
@@ -171,7 +172,7 @@ static void avro_schema_free(avro_schema
struct avro_link_schema_t *link;
link = avro_schema_to_link(schema);
avro_schema_decref(link->to);
- free(link);
+ g_avro_allocator.free(link);
}
break;
}
@@ -277,14 +278,14 @@ avro_schema_t avro_schema_null(void)
avro_schema_t avro_schema_fixed(const char *name, const int64_t size)
{
struct avro_fixed_schema_t *fixed =
- malloc(sizeof(struct avro_fixed_schema_t));
+ g_avro_allocator.malloc(sizeof(struct avro_fixed_schema_t));
if (!fixed) {
return NULL;
}
if (!is_avro_id(name)) {
return NULL;
}
- fixed->name = strdup(name);
+ fixed->name = avro_strdup(name);
fixed->size = size;
avro_schema_init(&fixed->obj, AVRO_FIXED);
return &fixed->obj;
@@ -293,13 +294,13 @@ avro_schema_t avro_schema_fixed(const ch
avro_schema_t avro_schema_union(void)
{
struct avro_union_schema_t *schema =
- malloc(sizeof(struct avro_union_schema_t));
+ g_avro_allocator.malloc(sizeof(struct avro_union_schema_t));
if (!schema) {
return NULL;
}
schema->branches = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!schema->branches) {
- free(schema);
+ g_avro_allocator.free(schema);
return NULL;
}
@@ -325,7 +326,7 @@ avro_schema_union_append(const avro_sche
avro_schema_t avro_schema_array(const avro_schema_t items)
{
struct avro_array_schema_t *array =
- malloc(sizeof(struct avro_array_schema_t));
+ g_avro_allocator.malloc(sizeof(struct avro_array_schema_t));
if (!array) {
return NULL;
}
@@ -337,7 +338,7 @@ avro_schema_t avro_schema_array(const av
avro_schema_t avro_schema_map(const avro_schema_t values)
{
struct avro_map_schema_t *map =
- malloc(sizeof(struct avro_map_schema_t));
+ g_avro_allocator.malloc(sizeof(struct avro_map_schema_t));
if (!map) {
return NULL;
}
@@ -353,26 +354,26 @@ avro_schema_t avro_schema_enum(const cha
if (!is_avro_id(name)) {
return NULL;
}
- enump = malloc(sizeof(struct avro_enum_schema_t));
+ enump = g_avro_allocator.malloc(sizeof(struct avro_enum_schema_t));
if (!enump) {
return NULL;
}
- enump->name = strdup(name);
+ enump->name = avro_strdup(name);
if (!enump->name) {
- free(enump);
+ g_avro_allocator.free(enump);
return NULL;
}
enump->symbols = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!enump->symbols) {
- free(enump->name);
- free(enump);
+ g_avro_allocator.free(enump->name);
+ g_avro_allocator.free(enump);
return NULL;
}
enump->symbols_byname = st_init_strtable_with_size(DEFAULT_TABLE_SIZE);
if (!enump->symbols_byname) {
st_free_table(enump->symbols);
- free(enump->name);
- free(enump);
+ g_avro_allocator.free(enump->name);
+ g_avro_allocator.free(enump);
return NULL;
}
avro_schema_init(&enump->obj, AVRO_ENUM);
@@ -390,7 +391,7 @@ avro_schema_enum_symbol_append(const avr
return EINVAL;
}
enump = avro_schema_to_enum(enum_schema);
- sym = strdup(symbol);
+ sym = avro_strdup(symbol);
if (!sym) {
return ENOMEM;
}
@@ -413,7 +414,7 @@ avro_schema_record_field_append(const av
return EINVAL;
}
record = avro_schema_to_record(record_schema);
- new_field = malloc(sizeof(struct avro_record_field_t));
+ new_field = g_avro_allocator.malloc(sizeof(struct avro_record_field_t));
if (!new_field) {
return ENOMEM;
}
@@ -432,35 +433,35 @@ avro_schema_t avro_schema_record(const c
if (!is_avro_id(name)) {
return NULL;
}
- record = malloc(sizeof(struct avro_record_schema_t));
+ record = g_avro_allocator.malloc(sizeof(struct avro_record_schema_t));
if (!record) {
return NULL;
}
- record->name = strdup(name);
+ record->name = avro_strdup(name);
if (!record->name) {
- free(record);
+ g_avro_allocator.free(record);
return NULL;
}
- record->space = space ? strdup(space) : NULL;
+ record->space = space ? avro_strdup(space) : NULL;
if (space && !record->space) {
- free(record->name);
- free(record);
+ g_avro_allocator.free(record->name);
+ g_avro_allocator.free(record);
return NULL;
}
record->fields = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!record->fields) {
if (record->space) {
- free(record->space);
+ g_avro_allocator.free(record->space);
}
- free(record->name);
- free(record);
+ g_avro_allocator.free(record->name);
+ g_avro_allocator.free(record);
return NULL;
}
record->fields_byname = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!record->fields_byname) {
st_free_table(record->fields);
- free(record->name);
- free(record);
+ g_avro_allocator.free(record->name);
+ g_avro_allocator.free(record);
return NULL;
}
record->num_fields = 0;
@@ -497,7 +498,7 @@ avro_schema_t avro_schema_link(avro_sche
if (!is_avro_named_type(to)) {
return NULL;
}
- link = malloc(sizeof(struct avro_link_schema_t));
+ link = g_avro_allocator.malloc(sizeof(struct avro_link_schema_t));
if (!link) {
return NULL;
}
@@ -854,7 +855,7 @@ avro_schema_from_json(const char *jsonte
return EINVAL;
}
- error = malloc(sizeof(struct avro_schema_error_t_));
+ error = g_avro_allocator.malloc(sizeof(struct avro_schema_error_t_));
if (!error) {
return ENOMEM;
}
@@ -862,14 +863,14 @@ avro_schema_from_json(const char *jsonte
error->named_schemas = st_init_strtable_with_size(DEFAULT_TABLE_SIZE);
if (!error->named_schemas) {
- free(error);
+ g_avro_allocator.free(error);
return ENOMEM;
}
root = json_loads(jsontext, &error->json_error);
if (!root) {
st_free_table(error->named_schemas);
- free(error);
+ g_avro_allocator.free(error);
return EINVAL;
}
@@ -881,7 +882,7 @@ avro_schema_from_json(const char *jsonte
st_free_table(error->named_schemas);
if (rval == 0) {
/* no need for an error return */
- free(error);
+ g_avro_allocator.free(error);
}
return rval;
}
Modified: avro/trunk/lang/c/src/st.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/st.c?rev=947385&r1=947384&r2=947385&view=diff
==============================================================================
--- avro/trunk/lang/c/src/st.c (original)
+++ avro/trunk/lang/c/src/st.c Sun May 23 09:06:55 2010
@@ -13,6 +13,7 @@
#include <string.h>
#include "st.h"
+#include "allocator.h"
typedef struct st_table_entry st_table_entry;
@@ -58,8 +59,8 @@ static void rehash(st_table *);
#define calloc xcalloc
#endif
-#define alloc(type) (type*)malloc((unsigned)sizeof(type))
-#define Calloc(n,s) (char*)calloc((n),(s))
+#define alloc(type) (type*)g_avro_allocator.malloc((unsigned)sizeof(type))
+#define Calloc(n,s) (char*)g_avro_allocator.calloc((n),(s))
#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
@@ -207,12 +208,12 @@ st_table *table;
ptr = table->bins[i];
while (ptr != 0) {
next = ptr->next;
- free(ptr);
+ g_avro_allocator.free(ptr);
ptr = next;
}
}
- free(table->bins);
- free(table);
+ g_avro_allocator.free(table->bins);
+ g_avro_allocator.free(table);
}
#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
@@ -327,7 +328,7 @@ register st_table *table;
ptr = next;
}
}
- free(table->bins);
+ g_avro_allocator.free(table->bins);
table->num_bins = new_num_bins;
table->bins = new_bins;
}
@@ -349,7 +350,7 @@ st_table *old_table;
Calloc((unsigned)num_bins, sizeof(st_table_entry *));
if (new_table->bins == 0) {
- free(new_table);
+ g_avro_allocator.free(new_table);
return 0;
}
@@ -359,8 +360,8 @@ st_table *old_table;
while (ptr != 0) {
entry = alloc(st_table_entry);
if (entry == 0) {
- free(new_table->bins);
- free(new_table);
+ g_avro_allocator.free(new_table->bins);
+ g_avro_allocator.free(new_table);
return 0;
}
*entry = *ptr;
@@ -396,7 +397,7 @@ st_data_t *value;
if (value != 0)
*value = ptr->record;
*key = ptr->key;
- free(ptr);
+ g_avro_allocator.free(ptr);
return 1;
}
@@ -408,7 +409,7 @@ st_data_t *value;
if (value != 0)
*value = tmp->record;
*key = tmp->key;
- free(tmp);
+ g_avro_allocator.free(tmp);
return 1;
}
}
@@ -515,7 +516,7 @@ st_data_t arg;
last->next = ptr->next;
}
ptr = ptr->next;
- free(tmp);
+ g_avro_allocator.free(tmp);
table->num_entries--;
}
}