1 /*******************************************************************
2 uLan Utilities Library - C library of basic reusable constructions
4 ul_hptree.c - heap tree implementation
6 (C) Copyright 2003-2004 by Pavel Pisa - Originator
8 The uLan utilities library can be used, copied and modified under
10 - GPL - GNU General Public License
11 - LGPL - GNU Lesser General Public License
12 - MPL - Mozilla Public License
13 - and other licenses added by project originators
14 Code can be modified and re-distributed under any combination
15 of the above listed licenses. If contributor does not agree with
16 some of the licenses, he/she can delete appropriate line.
17 Warning, if you delete all lines, you are not allowed to
18 distribute source code and/or binaries utilizing code.
20 See files COPYING and README for details.
22 *******************************************************************/
25 #include "ul_utmalloc.h"
26 #include "ul_hptree.h"
28 int ul_hpt_init_root_hpt(ul_hpt_root_field_t *hpt_root, int acapacity)
32 hpt_root->capacity=acapacity;
33 ha=malloc(hpt_root->capacity*sizeof(void *));
35 hpt_root->heaparr=NULL;
39 hpt_root->heaparr=ha-1;
43 int ul_hpt_enlarge_hpt(ul_hpt_root_field_t *hpt_root)
47 acap=hpt_root->capacity;
48 acap=((acap+7)&(~7))*2;
49 ha=realloc(hpt_root->heaparr+1,acap*sizeof(void *));
51 hpt_root->capacity=acap;
52 hpt_root->heaparr=ha-1;
56 void ul_hpt_done_root_hpt(ul_hpt_root_field_t *hpt_root)
59 free(hpt_root->heaparr+1);