Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
comparison PrivateQueue.c @ 43:d01d48b023ca
Renamed VMS to PR, in new branch
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Mon, 03 Sep 2012 15:07:45 -0700 |
| parents | b9cb01d8ce56 |
| children | 67c7f5a0308b |
comparison
equal
deleted
inserted
replaced
| 23:f63ccb59d744 | 26:09472937dd57 |
|---|---|
| 25 | 25 |
| 26 PrivQueueStruc* makePrivQ() | 26 PrivQueueStruc* makePrivQ() |
| 27 { | 27 { |
| 28 PrivQueueStruc* retQ; | 28 PrivQueueStruc* retQ; |
| 29 //This malloc is not safe to use in wrapper lib nor app code! | 29 //This malloc is not safe to use in wrapper lib nor app code! |
| 30 retQ = (PrivQueueStruc *) VMS_int__malloc( sizeof( PrivQueueStruc ) ); | 30 retQ = (PrivQueueStruc *) PR_int__malloc( sizeof( PrivQueueStruc ) ); |
| 31 | 31 |
| 32 //This malloc is not safe to use in wrapper lib nor app code! | 32 //This malloc is not safe to use in wrapper lib nor app code! |
| 33 retQ->startOfData = VMS_int__malloc( 1024 * sizeof(void *) ); | 33 retQ->startOfData = PR_int__malloc( 1024 * sizeof(void *) ); |
| 34 memset( retQ->startOfData, 0, 1024 * sizeof(void *) ); | 34 memset( retQ->startOfData, 0, 1024 * sizeof(void *) ); |
| 35 retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty | 35 retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty |
| 36 retQ->insertPos = &(retQ->startOfData[1]); // so start pos's have to be | 36 retQ->insertPos = &(retQ->startOfData[1]); // so start pos's have to be |
| 37 retQ->endOfData = &(retQ->startOfData[1023]); | 37 retQ->endOfData = &(retQ->startOfData[1023]); |
| 38 | 38 |
| 59 | 59 |
| 60 oldSize = oldEndOfData - oldStartOfData + 1; //in bytes | 60 oldSize = oldEndOfData - oldStartOfData + 1; //in bytes |
| 61 newSize = 2 * oldSize; | 61 newSize = 2 * oldSize; |
| 62 | 62 |
| 63 //This malloc is not safe to use in wrapper lib nor app code! | 63 //This malloc is not safe to use in wrapper lib nor app code! |
| 64 Q->startOfData = (void **)VMS_int__malloc( newSize ); | 64 Q->startOfData = (void **)PR_int__malloc( newSize ); |
| 65 newStartOfData = (int8 *)Q->startOfData; | 65 newStartOfData = (int8 *)Q->startOfData; |
| 66 newEndOfData = newStartOfData + newSize; //all calcs in Bytes | 66 newEndOfData = newStartOfData + newSize; //all calcs in Bytes |
| 67 Q->endOfData = (void **)newEndOfData; | 67 Q->endOfData = (void **)newEndOfData; |
| 68 | 68 |
| 69 //TODO: test all of this, for both cases | 69 //TODO: test all of this, for both cases |
| 97 bottPartSize = oldSize - topPartSize - 1; //-1 for empty insertPos | 97 bottPartSize = oldSize - topPartSize - 1; //-1 for empty insertPos |
| 98 memcpy( newStartOfData, oldStartOfData, bottPartSize ); | 98 memcpy( newStartOfData, oldStartOfData, bottPartSize ); |
| 99 Q->insertPos = (void **)(newStartOfData + bottPartSize); | 99 Q->insertPos = (void **)(newStartOfData + bottPartSize); |
| 100 } | 100 } |
| 101 //This free is not safe to use in wrapper lib nor app code! | 101 //This free is not safe to use in wrapper lib nor app code! |
| 102 VMS_int__free(oldStartOfData); | 102 PR_int__free(oldStartOfData); |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 /*Returns TRUE when queue is empty | 106 /*Returns TRUE when queue is empty |
| 107 */ | 107 */ |
| 285 | 285 |
| 286 void | 286 void |
| 287 freePrivQ( PrivQueueStruc *Q ) | 287 freePrivQ( PrivQueueStruc *Q ) |
| 288 { | 288 { |
| 289 //This free is not safe to use in wrapper lib nor app code! | 289 //This free is not safe to use in wrapper lib nor app code! |
| 290 VMS_int__free( Q->startOfData ); | 290 PR_int__free( Q->startOfData ); |
| 291 VMS_int__free( Q ); | 291 PR_int__free( Q ); |
| 292 } | 292 } |
