儲存庫 vbox 的更動 101946
- 時間撮記:
- 2023-11-7 下午03:16:08 (13 月 以前)
- 位置:
- trunk/src/libs/xpcom18a4/nsprpub/lib/ds
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.c
r101869 r101946 45 45 #include <string.h> 46 46 #include "plarena.h" 47 #include "prmem.h"48 47 #include "prbit.h" 49 #include "prlog.h" 50 #include "prlock.h" 51 #include "prinit.h" 48 49 #include <iprt/assert.h> 50 #include <iprt/errcore.h> 51 #include <iprt/mem.h> 52 #include <iprt/once.h> 53 #include <iprt/semaphore.h> 52 54 53 55 static PLArena *arena_freelist; 54 56 55 #define COUNT(pool,what)56 57 #define PL_ARENA_DEFAULT_ALIGN sizeof(double) 57 58 58 static PRLock *arenaLock;59 static PRCallOnceType once;59 static RTSEMFASTMUTEX g_hMtxArena = NIL_RTSEMFASTMUTEX; 60 static RTONCE g_rtOnce = RTONCE_INITIALIZER; 60 61 61 62 /* … … 73 74 ** 74 75 */ 75 static PRStatus InitializeArenas( void ) 76 { 77 PR_ASSERT( arenaLock == NULL ); 78 arenaLock = PR_NewLock(); 79 if ( arenaLock == NULL ) 76 static DECLCALLBACK(int) InitializeArenas(void *pvUser) 77 { 78 RT_NOREF(pvUser); 79 Assert(g_hMtxArena == NIL_RTSEMFASTMUTEX); 80 81 return RTSemFastMutexCreate(&g_hMtxArena); 82 } /* end ArenaInitialize() */ 83 84 static PRStatus LockArena( void ) 85 { 86 int vrc = RTOnce(&g_rtOnce, InitializeArenas, NULL /*pvUser*/); 87 if (RT_FAILURE(vrc)) 80 88 return PR_FAILURE; 81 else 82 return PR_SUCCESS; 83 } /* end ArenaInitialize() */ 84 85 static PRStatus LockArena( void ) 86 { 87 PRStatus rc = PR_CallOnce( &once, InitializeArenas ); 88 89 if ( PR_FAILURE != rc ) 90 PR_Lock( arenaLock ); 91 return(rc); 89 90 RTSemFastMutexRequest(g_hMtxArena); 91 return PR_SUCCESS; 92 92 } /* end LockArena() */ 93 93 94 94 static void UnlockArena( void ) 95 95 { 96 PR_Unlock( arenaLock);96 RTSemFastMutexRelease(g_hMtxArena); 97 97 return; 98 98 } /* end UnlockArena() */ … … 147 147 PRUint32 nbOld; 148 148 149 PR_ASSERT((nb & pool->mask) == 0);150 149 Assert((nb & pool->mask) == 0); 150 151 151 nbOld = nb; 152 152 nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */ … … 202 202 PRUint32 sz = PR_MAX(pool->arenasize, nb); 203 203 sz += sizeof *a + pool->mask; /* header and alignment slop */ 204 a = (PLArena*) PR_MALLOC(sz);204 a = (PLArena*)RTMemAlloc(sz); 205 205 if ( NULL != a ) { 206 206 a->limit = (PRUword)a + sz; … … 208 208 rp = (char *)a->avail; 209 209 a->avail += nb; 210 PR_ASSERT(a->avail <= a->limit);210 Assert(a->avail <= a->limit); 211 211 /* the newly allocated arena is linked after pool->current 212 212 * and becomes pool->current */ … … 217 217 pool->first.next = a; 218 218 PL_COUNT_ARENA(pool,++); 219 COUNT(pool, nmallocs);220 219 return(rp); 221 220 } … … 254 253 #ifdef DEBUG 255 254 do { 256 PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);255 Assert(a->base <= a->avail && a->avail <= a->limit); 257 256 a->avail = a->base; 258 257 PL_CLEAR_UNUSED(a); … … 266 265 PL_CLEAR_ARENA(a); 267 266 PL_COUNT_ARENA(pool,--); 268 PR_DELETE(a);267 RTMemFree(a); 269 268 } while ((a = *ap) != 0); 270 269 } else { … … 299 298 { 300 299 FreeArenaList(pool, &pool->first, PR_FALSE); 301 COUNT(pool, ndeallocs);302 300 } 303 301 … … 317 315 for (a = arena_freelist; a; a = next) { 318 316 next = a->next; 319 PR_DELETE(a);317 RTMemFree(a); 320 318 } 321 319 arena_freelist = NULL; 322 320 323 if ( arenaLock) {324 PR_DestroyLock(arenaLock);325 arenaLock = NULL;326 } 327 } 328 321 if (g_hMtxArena != NIL_RTSEMFASTMUTEX) { 322 RTSemFastMutexDestroy(g_hMtxArena); 323 g_hMtxArena = NIL_RTSEMFASTMUTEX; 324 } 325 } 326 -
trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.h
r101869 r101946 123 123 #ifdef DEBUG 124 124 #define PL_FREE_PATTERN 0xDA 125 #define PL_CLEAR_UNUSED(a) (PR_ASSERT((a)->avail <= (a)->limit),\125 #define PL_CLEAR_UNUSED(a) Assert((a)->avail <= (a)->limit); \ 126 126 memset((void*)(a)->avail, PL_FREE_PATTERN, \ 127 (a)->limit - (a)->avail) )127 (a)->limit - (a)->avail) 128 128 #define PL_CLEAR_ARENA(a) memset((void*)(a), PL_FREE_PATTERN, \ 129 129 (a)->limit - (PRUword)(a))
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器