6 CDict
*cdict_alloc(int n
)
10 d
=calloc(1,sizeof(CDict
));
11 if (d
==0) /* calloc FAILED!! */
13 d
->dict
=calloc(n
,sizeof(CDictEntry
));
14 if (d
->dict
==0) { /* calloc FAILED!! */
15 free(d
); /* DUMP OUR EMPTY STRUCTURE */
18 return d
; /* RETURN OUR DATA STRUCTURE */
22 int cdict_free(CDict
*d
)
30 int cdict_qsort_cmp(const void *void_a
,const void *void_b
)
31 { /* STRAIGHTFORWARD COMPARISON OF SIGNED start VALUES, LONGER INTERVALS 1ST */
32 CDictEntry
*a
=(CDictEntry
*)void_a
,*b
=(CDictEntry
*)void_b
;
42 CDictEntry
*cdict_getitem(CDict
*d
,int k
)
47 if (d
==0) /* HANDLE NULL POINTER PROPERLY */
50 p
=d
->dict
; /* SORTED ARRAY OF ENTRIES */
66 CGraph
*cgraph_alloc(int n
)
70 d
=calloc(1,sizeof(CGraph
));
71 if (d
==0) /* calloc FAILED!! */
73 d
->dict
=calloc(n
,sizeof(CGraphEntry
));
74 if (d
->dict
==0) { /* calloc FAILED!! */
75 free(d
); /* DUMP OUR EMPTY STRUCTURE */
78 return d
; /* RETURN OUR DATA STRUCTURE */
82 int cgraph_free(CGraph
*d
)
85 for (i
=0;i
<d
->n
;i
++) /* DUMP ALL ASSOCIATED DICTIONARIES */
86 cdict_free(d
->dict
[i
].v
);
93 CGraphEntry
*cgraph_getitem(CGraph
*d
,int k
)
98 if (d
==0) /* HANDLE NULL POINTER PROPERLY */
101 p
=d
->dict
; /* SORTED ARRAY OF ENTRIES */
116 int *calloc_int(int n
)
118 return (int *)calloc(n
,sizeof(int));