Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > PriorityQueue
comparison PriorityQueue.c @ 5:09e51191078a
updated for VMS name chgs from VMS__malloc to VMS_int__malloc
| author | Me@portablequad |
|---|---|
| date | Sun, 12 Feb 2012 01:45:04 -0800 |
| parents | 7254bef12749 |
| children | 40cad2a2fffc |
comparison
equal
deleted
inserted
replaced
| 3:6feaa06de6ee | 4:e791a39347d8 |
|---|---|
| 18 #define right(i) 2*i+1 | 18 #define right(i) 2*i+1 |
| 19 #define parent(i) i/2 | 19 #define parent(i) i/2 |
| 20 | 20 |
| 21 #ifdef DEBUG | 21 #ifdef DEBUG |
| 22 #include <stdlib.h> | 22 #include <stdlib.h> |
| 23 #define VMS__malloc malloc | 23 #define VMS_WL__malloc malloc |
| 24 #define VMS__free free | 24 #define VMS_WL__free free |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 void swap (PrioQueueStruc *Q, int a, int b) { | 27 void swap (PrioQueueStruc *Q, int a, int b) { |
| 28 void *valTmp; | 28 void *valTmp; |
| 29 int keyTmp; | 29 int keyTmp; |
| 67 | 67 |
| 68 oldSize= Q->size; | 68 oldSize= Q->size; |
| 69 newSize= 2*oldSize; | 69 newSize= 2*oldSize; |
| 70 | 70 |
| 71 Q->maxSize= newSize; | 71 Q->maxSize= newSize; |
| 72 newData= VMS__malloc(Q->maxSize*sizeof(heapNode)); | 72 newData= VMS_WL__malloc(Q->maxSize*sizeof(heapNode)); |
| 73 oldData= Q->data; | 73 oldData= Q->data; |
| 74 | 74 |
| 75 memcpy(newData,oldData,Q->maxSize*sizeof(heapNode)); | 75 memcpy(newData,oldData,Q->maxSize*sizeof(heapNode)); |
| 76 Q->data= newData; | 76 Q->data= newData; |
| 77 | 77 |
| 78 VMS__free(oldData); | 78 VMS_WL__free(oldData); |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 PrioQueueStruc* makePrioQ () { | 82 PrioQueueStruc* makePrioQ () { |
| 83 PrioQueueStruc *retQ; | 83 PrioQueueStruc *retQ; |
| 84 retQ= VMS__malloc(sizeof(PrioQueueStruc)); | 84 retQ= VMS_int__malloc(sizeof(PrioQueueStruc)); |
| 85 retQ->maxSize= 1024; | 85 retQ->maxSize= 1024; |
| 86 retQ->data= VMS__malloc(retQ->maxSize*sizeof(heapNode)); | 86 retQ->data= VMS_int__malloc(retQ->maxSize*sizeof(heapNode)); |
| 87 retQ->size= 0; | 87 retQ->size= 0; |
| 88 return retQ; | 88 return retQ; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void* getFirstPrioQ (PrioQueueStruc *Q) { | 91 void* getFirstPrioQ (PrioQueueStruc *Q) { |
| 122 printf("} ... "); | 122 printf("} ... "); |
| 123 | 123 |
| 124 } | 124 } |
| 125 | 125 |
| 126 void freePrioQ (PrioQueueStruc *Q) { | 126 void freePrioQ (PrioQueueStruc *Q) { |
| 127 VMS__free(Q->data); | 127 VMS_int__free(Q->data); |
| 128 VMS__free(Q); | 128 VMS_int__free(Q); |
| 129 } | 129 } |
