Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
changeset 9:62326cc8e6f4 VMS__malloc_brch
This branch has replace malloc and free with VMS__malloc and VMS__free
| author | Me |
|---|---|
| date | Sun, 31 Oct 2010 20:24:00 -0700 |
| parents | 93bf3ffcc1fb |
| children | 88efea74818a |
| files | BlockingQueue.c BlockingQueue.h PrivateQueue.c |
| diffstat | 3 files changed, 21 insertions(+), 14 deletions(-) [+] |
line diff
1.1 --- a/BlockingQueue.c Tue Sep 07 18:57:51 2010 -0700 1.2 +++ b/BlockingQueue.c Sun Oct 31 20:24:00 2010 -0700 1.3 @@ -25,7 +25,7 @@ 1.4 { 1.5 PThdQueueStruc* retQ; 1.6 int retCode; 1.7 - retQ = (PThdQueueStruc *) malloc( sizeof( PThdQueueStruc ) ); 1.8 + retQ = (PThdQueueStruc *) VMS__malloc( sizeof( PThdQueueStruc ) ); 1.9 1.10 1.11 retCode = 1.12 @@ -117,7 +117,7 @@ 1.13 CASQueueStruc* makeCASQ() 1.14 { 1.15 CASQueueStruc* retQ; 1.16 - retQ = (CASQueueStruc *) malloc( sizeof( CASQueueStruc ) ); 1.17 + retQ = (CASQueueStruc *) VMS__malloc( sizeof( CASQueueStruc ) ); 1.18 1.19 retQ->insertLock = UNLOCKED; 1.20 retQ->extractLock= UNLOCKED; 1.21 @@ -242,7 +242,7 @@ 1.22 SRSWQueueStruc* makeSRSWQ() 1.23 { 1.24 SRSWQueueStruc* retQ; 1.25 - retQ = (SRSWQueueStruc *) malloc( sizeof( SRSWQueueStruc ) ); 1.26 + retQ = (SRSWQueueStruc *) VMS__malloc( sizeof( SRSWQueueStruc ) ); 1.27 1.28 retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty 1.29 retQ->insertPos = &(retQ->startOfData[1]); // so start pos's have to be 1.30 @@ -380,11 +380,11 @@ 1.31 SRMWQueueStruc* makeSRMWQ() 1.32 { SRMWQueueStruc* retQ; 1.33 1.34 - retQ = (SRMWQueueStruc *) malloc( sizeof( SRMWQueueStruc ) ); 1.35 + retQ = (SRMWQueueStruc *) VMS__malloc( sizeof( SRMWQueueStruc ) ); 1.36 1.37 retQ->numInternalQs = 0; 1.38 retQ->internalQsSz = 10; 1.39 - retQ->internalQs = malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *)); 1.40 + retQ->internalQs = VMS__malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *)); 1.41 1.42 retQ->lastQReadFrom = 0; 1.43 1.44 @@ -410,7 +410,7 @@ 1.45 oldSz = Q->internalQsSz; 1.46 oldArray = Q->internalQs; 1.47 Q->internalQsSz *= 2; 1.48 - Q->internalQs = malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *)); 1.49 + Q->internalQs = VMS__malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *)); 1.50 for( i = 0; i < oldSz; i++ ) 1.51 { Q->internalQs[i] = oldArray[i]; 1.52 }
2.1 --- a/BlockingQueue.h Tue Sep 07 18:57:51 2010 -0700 2.2 +++ b/BlockingQueue.h Sun Oct 31 20:24:00 2010 -0700 2.3 @@ -42,10 +42,10 @@ 2.4 //========== CAS based queue ========== 2.5 typedef 2.6 struct 2.7 - { volatile int insertLock; 2.8 - volatile int extractLock; 2.9 - volatile void* *insertPos; 2.10 - volatile void* *extractPos; 2.11 + { int insertLock; 2.12 + int extractLock; 2.13 + void* *insertPos; 2.14 + void* *extractPos; 2.15 void* startOfData[1024]; //data is pointers 2.16 void* *endOfData; //set when make queue 2.17 }
3.1 --- a/PrivateQueue.c Tue Sep 07 18:57:51 2010 -0700 3.2 +++ b/PrivateQueue.c Sun Oct 31 20:24:00 2010 -0700 3.3 @@ -26,9 +26,9 @@ 3.4 PrivQueueStruc* makePrivQ() 3.5 { 3.6 PrivQueueStruc* retQ; 3.7 - retQ = (PrivQueueStruc *) malloc( sizeof( PrivQueueStruc ) ); 3.8 + retQ = (PrivQueueStruc *) VMS__malloc( sizeof( PrivQueueStruc ) ); 3.9 3.10 - retQ->startOfData = malloc( 1024 * sizeof(void *) ); 3.11 + retQ->startOfData = VMS__malloc( 1024 * sizeof(void *) ); 3.12 3.13 retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty 3.14 retQ->insertPos = &(retQ->startOfData[1]); // so start pos's have to be 3.15 @@ -46,9 +46,9 @@ 3.16 oldSize = Q->endOfData - Q->startOfData; 3.17 newSize = 2 * oldSize; 3.18 oldStartOfData = Q->startOfData; 3.19 - Q->startOfData = malloc( newSize * sizeof(void *) ); 3.20 + Q->startOfData = VMS__malloc( newSize * sizeof(void *) ); 3.21 memcpy(Q->startOfData, oldStartOfData, oldSize * sizeof(void *)); 3.22 - free(oldStartOfData); 3.23 + VMS__free(oldStartOfData); 3.24 3.25 Q->extractPos = &(Q->startOfData[0]); //side by side == empty 3.26 Q->insertPos = &(Q->startOfData[1]); // so start pos's have to be 3.27 @@ -139,3 +139,10 @@ 3.28 //Q is full 3.29 return FALSE; 3.30 } 3.31 + 3.32 +void 3.33 +freePrivQ( PrivQueueStruc *Q ) 3.34 + { 3.35 + VMS__free( Q->startOfData ); 3.36 + VMS__free( Q ); 3.37 + } 3.38 \ No newline at end of file
