hash.c: K&R conversion to ANSI and constify arguments / callback
cb_heap_kill_t callback typedef created Invoked from HeapKill() No active callback implementation in the codebase. callback interface (from hash.h): marked @invoke call-site
This commit is contained in:
parent
d9cfd64d60
commit
ff9487de1f
|
|
@ -139,7 +139,7 @@ GlGlobalRoute(chanList, netList)
|
|||
glPenClearPerChan(net);
|
||||
RtrMilestonePrint();
|
||||
}
|
||||
HeapKill(&netHeap, (void (*)()) NULL);
|
||||
HeapKill(&netHeap, (cb_heap_kill_t) NULL);
|
||||
|
||||
glClientFree(chanList, netList);
|
||||
glChanFreeMap();
|
||||
|
|
@ -333,7 +333,7 @@ glProcessLoc(startList, loc, bestCost, doFast)
|
|||
headFree = glPathCurPage->glp_free;
|
||||
bestPt = glMazeFindPath(loc, bestCost);
|
||||
glMazeResetCost(headPage, headFree);
|
||||
HeapKill(&glMazeHeap, (void (*)()) NULL);
|
||||
HeapKill(&glMazeHeap, (cb_heap_kill_t) NULL);
|
||||
if (bestPt == (GlPoint *) NULL)
|
||||
{
|
||||
glBadRoutes++;
|
||||
|
|
@ -372,7 +372,7 @@ glProcessLoc(startList, loc, bestCost, doFast)
|
|||
}
|
||||
if (doFast)
|
||||
glMazeResetCost(headPage, headFree);
|
||||
HeapKill(&glMazeHeap, (void (*)()) NULL);
|
||||
HeapKill(&glMazeHeap, (cb_heap_kill_t) NULL);
|
||||
if (bestPt)
|
||||
{
|
||||
if (glLogFile)
|
||||
|
|
|
|||
|
|
@ -241,8 +241,8 @@ glRouteToPoint(loc, bestCost)
|
|||
glHistoAdd(heapPts, frontierPts, startPts);
|
||||
|
||||
/* Free the auxiliary heaps */
|
||||
HeapKill(&glBestHeap, (void (*)()) NULL);
|
||||
HeapKill(&glProximityHeap, (void (*)()) NULL);
|
||||
HeapKill(&glBestHeap, (cb_heap_kill_t) NULL);
|
||||
HeapKill(&glProximityHeap, (cb_heap_kill_t) NULL);
|
||||
|
||||
return (lastPt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ glHistoDump()
|
|||
}
|
||||
count++, total++;
|
||||
}
|
||||
HeapKill(&histoHeap, (void (*)()) NULL);
|
||||
HeapKill(&histoHeap, (cb_heap_kill_t) NULL);
|
||||
if (count > 0)
|
||||
fprintf(fp, "%d: %d\n", lastsize, count);
|
||||
fprintf(fp, "TOTAL: %d\n", total);
|
||||
|
|
@ -499,7 +499,7 @@ glHistoDump()
|
|||
}
|
||||
count++, total++;
|
||||
}
|
||||
HeapKill(&histoHeap, (void (*)()) NULL);
|
||||
HeapKill(&histoHeap, (cb_heap_kill_t) NULL);
|
||||
if (count > 0)
|
||||
fprintf(fp, "%d: %d\n", lastsize, count);
|
||||
fprintf(fp, "TOTAL: %d\n", total);
|
||||
|
|
|
|||
|
|
@ -1550,7 +1550,7 @@ mzAssignVertexCosts()
|
|||
}
|
||||
|
||||
/* Free heap */
|
||||
HeapKill(&adjHeap, (void (*)()) NULL);
|
||||
HeapKill(&adjHeap, (cb_heap_kill_t) NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1292,10 +1292,10 @@ MZClean()
|
|||
/* Free up route-path queues */
|
||||
if(mzPathsDirty)
|
||||
{
|
||||
HeapKill(&mzMaxToGoHeap, (void (*)()) NULL);
|
||||
HeapKill(&mzMinCostHeap, (void (*)()) NULL);
|
||||
HeapKill(&mzMinAdjCostHeap, (void (*)()) NULL);
|
||||
HeapKill(&mzMinCostCompleteHeap, (void (*)()) NULL);
|
||||
HeapKill(&mzMaxToGoHeap, (cb_heap_kill_t) NULL);
|
||||
HeapKill(&mzMinCostHeap, (cb_heap_kill_t) NULL);
|
||||
HeapKill(&mzMinAdjCostHeap, (cb_heap_kill_t) NULL);
|
||||
HeapKill(&mzMinCostCompleteHeap, (cb_heap_kill_t) NULL);
|
||||
ListDealloc(mzBloomStack);
|
||||
ListDealloc(mzStraightStack);
|
||||
ListDealloc(mzDownHillStack);
|
||||
|
|
|
|||
96
utils/heap.c
96
utils/heap.c
|
|
@ -111,22 +111,22 @@ extern void heapify();
|
|||
*/
|
||||
|
||||
void
|
||||
HeapInit(heap, size, descending, stringIds)
|
||||
Heap *heap; /* Pointer to a heap struct */
|
||||
int size; /* Initial size of heap */
|
||||
int descending; /* TRUE if largest on top */
|
||||
int stringIds; /* TRUE if entry id's are strings */
|
||||
HeapInit(
|
||||
Heap *heap, /* Pointer to a heap struct */
|
||||
int size, /* Initial size of heap */
|
||||
int descending, /* TRUE if largest on top */
|
||||
int stringIds) /* TRUE if entry id's are strings */
|
||||
{
|
||||
HeapInitType(heap, size, descending, stringIds, HE_INT);
|
||||
}
|
||||
|
||||
void
|
||||
HeapInitType(heap, size, descending, stringIds, keyType)
|
||||
Heap *heap; /* Pointer to a heap struct */
|
||||
int size; /* Initial size of heap */
|
||||
int descending; /* TRUE if largest on top */
|
||||
int stringIds; /* TRUE if entry id's are strings */
|
||||
int keyType; /* Type of keys to use */
|
||||
HeapInitType(
|
||||
Heap *heap, /* Pointer to a heap struct */
|
||||
int size, /* Initial size of heap */
|
||||
int descending, /* TRUE if largest on top */
|
||||
int stringIds, /* TRUE if entry id's are strings */
|
||||
int keyType) /* Type of keys to use */
|
||||
{
|
||||
if (size < 0) size = -size;
|
||||
heap->he_size = 2;
|
||||
|
|
@ -177,9 +177,9 @@ HeapInitType(heap, size, descending, stringIds, keyType)
|
|||
*/
|
||||
|
||||
void
|
||||
HeapKill(heap, func)
|
||||
Heap *heap; /* The heap being killed */
|
||||
void (*func)(); /* Some function to free each id element */
|
||||
HeapKill(
|
||||
Heap *heap, /* The heap being killed */
|
||||
cb_heap_kill_t func) /* Some function to free each id element */
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ HeapKill(heap, func)
|
|||
*/
|
||||
if (func)
|
||||
for (i = 1; i <= heap->he_used; i++)
|
||||
(*func) (heap, i);
|
||||
(*func) (heap, i); /** @invoke cb_heap_kill_t */
|
||||
freeMagic((char *) heap->he_list);
|
||||
heap->he_list = NULL;
|
||||
}
|
||||
|
|
@ -212,9 +212,9 @@ HeapKill(heap, func)
|
|||
*/
|
||||
|
||||
void
|
||||
HeapFreeIdFunc(heap, i)
|
||||
Heap *heap; /* The heap in which the free is performed */
|
||||
int i; /* The index of the entry whose id gets freed */
|
||||
HeapFreeIdFunc(
|
||||
Heap *heap, /* The heap in which the free is performed */
|
||||
int i) /* The index of the entry whose id gets freed */
|
||||
{
|
||||
if (heap->he_stringId)
|
||||
freeMagic(heap->he_list[i].he_id);
|
||||
|
|
@ -239,9 +239,9 @@ HeapFreeIdFunc(heap, i)
|
|||
*/
|
||||
|
||||
HeapEntry *
|
||||
HeapRemoveTop(heap, entry)
|
||||
Heap *heap; /* The heap from which the top is removed */
|
||||
HeapEntry *entry; /* Return the value in this struct */
|
||||
HeapRemoveTop(
|
||||
Heap *heap, /* The heap from which the top is removed */
|
||||
HeapEntry *entry) /* Return the value in this struct */
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -278,8 +278,8 @@ HeapRemoveTop(heap, entry)
|
|||
*/
|
||||
|
||||
HeapEntry *
|
||||
HeapLookAtTop(heap)
|
||||
Heap *heap;
|
||||
HeapLookAtTop(
|
||||
Heap *heap)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -311,9 +311,9 @@ HeapLookAtTop(heap)
|
|||
*/
|
||||
|
||||
void
|
||||
heapify(heap, root)
|
||||
Heap *heap;
|
||||
int root;
|
||||
heapify(
|
||||
Heap *heap,
|
||||
int root)
|
||||
{
|
||||
HeapEntry *list = heap->he_list;
|
||||
int x, r, used = heap->he_used;
|
||||
|
|
@ -383,10 +383,10 @@ heapify(heap, root)
|
|||
*/
|
||||
|
||||
void
|
||||
HeapAdd(heap, pKey, id)
|
||||
Heap *heap;
|
||||
union heUnion *pKey;
|
||||
char *id;
|
||||
HeapAdd(
|
||||
Heap *heap,
|
||||
union heUnion *pKey,
|
||||
char *id)
|
||||
{
|
||||
HeapEntry *list = heap->he_list;
|
||||
int i, cmp, keyType;
|
||||
|
|
@ -462,10 +462,10 @@ HeapAdd(heap, pKey, id)
|
|||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
HeapAddInt(heap, data, id)
|
||||
Heap *heap;
|
||||
int data;
|
||||
char *id;
|
||||
HeapAddInt(
|
||||
Heap *heap,
|
||||
int data,
|
||||
char *id)
|
||||
{
|
||||
union heUnion pKey;
|
||||
|
||||
|
|
@ -476,10 +476,10 @@ HeapAddInt(heap, data, id)
|
|||
}
|
||||
|
||||
void
|
||||
HeapAddDLong(heap, data, id)
|
||||
Heap *heap;
|
||||
dlong data;
|
||||
char *id;
|
||||
HeapAddDLong(
|
||||
Heap *heap,
|
||||
dlong data,
|
||||
char *id)
|
||||
{
|
||||
union heUnion pKey;
|
||||
|
||||
|
|
@ -490,10 +490,10 @@ HeapAddDLong(heap, data, id)
|
|||
}
|
||||
|
||||
void
|
||||
HeapAddFloat(heap, data, id)
|
||||
Heap *heap;
|
||||
float data;
|
||||
char *id;
|
||||
HeapAddFloat(
|
||||
Heap *heap,
|
||||
float data,
|
||||
char *id)
|
||||
{
|
||||
union heUnion pKey;
|
||||
|
||||
|
|
@ -504,10 +504,10 @@ HeapAddFloat(heap, data, id)
|
|||
}
|
||||
|
||||
void
|
||||
HeapAddDouble(heap, data, id)
|
||||
Heap *heap;
|
||||
double data;
|
||||
char *id;
|
||||
HeapAddDouble(
|
||||
Heap *heap,
|
||||
double data,
|
||||
char *id)
|
||||
{
|
||||
union heUnion pKey;
|
||||
|
||||
|
|
@ -534,8 +534,8 @@ HeapAddDouble(heap, data, id)
|
|||
*/
|
||||
|
||||
void
|
||||
HeapDump(heap)
|
||||
Heap *heap;
|
||||
HeapDump(
|
||||
Heap *heap)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
|||
25
utils/heap.h
25
utils/heap.h
|
|
@ -125,18 +125,19 @@ typedef struct
|
|||
} Heap;
|
||||
|
||||
/* PROCEDURES */
|
||||
extern void HeapInit(Heap *, int, int, int);
|
||||
extern void HeapInitType(Heap *, int, int, int, int);
|
||||
extern void HeapKill(Heap *, void (*)());
|
||||
extern void HeapFreeIdFunc(Heap *, int);
|
||||
extern HeapEntry *HeapRemoveTop(Heap *, HeapEntry *);
|
||||
extern HeapEntry *HeapLookAtTop(Heap *);
|
||||
extern void HeapAdd(Heap *, union heUnion *, char *);
|
||||
extern void HeapAddInt(Heap *, int, char *);
|
||||
extern void HeapAddDLong(Heap *, dlong, char *);
|
||||
extern void HeapAddFloat(Heap *, float, char *);
|
||||
extern void HeapAddDouble(Heap *, double, char *);
|
||||
extern void HeapDump(Heap *);
|
||||
extern void HeapInit(Heap *heap, int size, int descending, int stringIds);
|
||||
extern void HeapInitType(Heap *heap, int size, int descending, int stringIds, int keyType);
|
||||
typedef void (*cb_heap_kill_t)(Heap *heap, int index);
|
||||
extern void HeapKill(Heap *heap, cb_heap_kill_t func);
|
||||
extern void HeapFreeIdFunc(Heap *heap, int i);
|
||||
extern HeapEntry *HeapRemoveTop(Heap *heap, HeapEntry *entry);
|
||||
extern HeapEntry *HeapLookAtTop(Heap *heap);
|
||||
extern void HeapAdd(Heap *heap, union heUnion *pKey, char *id);
|
||||
extern void HeapAddInt(Heap *heap, int data, char *id);
|
||||
extern void HeapAddDLong(Heap *heap, dlong data, char *id);
|
||||
extern void HeapAddFloat(Heap *heap, float data, char *id);
|
||||
extern void HeapAddDouble(Heap *heap, double data, char *id);
|
||||
extern void HeapDump(Heap *heap);
|
||||
|
||||
#define HEAP_EMPTY(h) ((h)->he_used == 0)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue