-
- new_heap_index = (void *) realloc( heap->heap_index, new_heap_size * heap->object_size );
- if ( NULL == new_heap_index )
- {
+ int bucket_index = new_heap_size / heap->heap_increment - 1;
+
+ if (bucket_index >= heap->num_buckets) {
+ int new_num_buckets = heap->num_buckets + 8;
+ void **new_bucket;
+
+ new_bucket = realloc(heap->bucket, new_num_buckets * sizeof(void *));
+ if (NULL == new_bucket) {
+ return -1;
+ }
+
+ heap->num_buckets = new_num_buckets;
+ heap->bucket = new_bucket;
+ }
+
+ new_heap_index = (void *) malloc(heap->heap_increment * heap->object_size);
+ if (NULL == new_heap_index) {