Changeset 31253 in vbox
- Timestamp:
- Jul 30, 2010 3:41:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/src/malloc/prmem.c
r11551 r31253 41 41 42 42 #include "primpl.h" 43 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR 44 # include <iprt/mem.h> 45 #endif 43 46 44 47 #ifdef _PR_ZONE_ALLOCATOR … … 54 57 */ 55 58 56 #include <string.h> 59 #include <string.h> 57 60 58 61 union memBlkHdrUn; … … 92 95 void 93 96 _PR_DestroyZones(void) 94 { 97 { 95 98 int i, j; 96 99 97 100 if (!use_zone_allocator) 98 101 return; 99 102 100 103 for (j = 0; j < THREAD_POOLS; j++) { 101 104 for (i = 0; i < MEM_ZONES; i++) { … … 109 112 } 110 113 } 111 } 114 } 112 115 use_zone_allocator = PR_FALSE; 113 } 116 } 114 117 115 118 /* … … 184 187 return; 185 188 186 for (j = 0; j < THREAD_POOLS; j++) { 189 for (j = 0; j < THREAD_POOLS; j++) { 187 190 for (i = 0; i < MEM_ZONES; i++) { 188 191 MemoryZone *mz = &zones[i][j]; … … 191 194 if (rv != 0) { 192 195 goto loser; 193 } 196 } 194 197 mz->blockSize = 16 << ( 2 * i); 195 198 } … … 365 368 PR_ASSERT(mt->s.zone == mb->s.zone); 366 369 PR_ASSERT(mt->s.blockSize == blockSize); 367 370 368 371 if (bytes <= blockSize) { 369 372 /* The block is already big enough. */ … … 373 376 ours = 1; 374 377 } 375 378 376 379 rv = pr_ZoneMalloc(bytes); 377 380 if (rv) { … … 438 441 if (!_pr_initialized) _PR_ImplicitInitialization(); 439 442 443 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR 444 return use_zone_allocator ? pr_ZoneMalloc(size) : RTMemAlloc(size); 445 #else 440 446 return use_zone_allocator ? pr_ZoneMalloc(size) : malloc(size); 447 #endif 441 448 } 442 449 … … 446 453 447 454 return use_zone_allocator ? 455 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR 456 pr_ZoneCalloc(nelem, elsize) : RTMemAllocZ(nelem * (size_t)elsize); 457 #else 448 458 pr_ZoneCalloc(nelem, elsize) : calloc(nelem, elsize); 459 #endif 449 460 } 450 461 … … 453 464 if (!_pr_initialized) _PR_ImplicitInitialization(); 454 465 466 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR 467 return use_zone_allocator ? pr_ZoneRealloc(ptr, size) : RTMemRealloc(ptr, size); 468 #else 455 469 return use_zone_allocator ? pr_ZoneRealloc(ptr, size) : realloc(ptr, size); 470 #endif 456 471 } 457 472 … … 461 476 pr_ZoneFree(ptr); 462 477 else 478 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR 479 RTMemFree(ptr); 480 #else 463 481 free(ptr); 482 #endif 464 483 } 465 484 … … 479 498 return PR_MD_malloc( (size_t) size); 480 499 #else 500 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR 501 return RTMemAlloc(size); 502 # else 481 503 return malloc(size); 504 # endif 482 505 #endif 483 506 } … … 487 510 #if defined (WIN16) 488 511 return PR_MD_calloc( (size_t)nelem, (size_t)elsize ); 489 490 #else 512 513 #else 514 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR 515 return RTMemAllocZ(nelem * (size_t)elsize); 516 # else 491 517 return calloc(nelem, elsize); 518 # endif 492 519 #endif 493 520 } … … 498 525 return PR_MD_realloc( ptr, (size_t) size); 499 526 #else 527 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR 528 return RTMemRealloc(ptr, size); 529 # else 500 530 return realloc(ptr, size); 531 # endif 501 532 #endif 502 533 } … … 507 538 PR_MD_free( ptr ); 508 539 #else 540 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR 541 RTMemFree(ptr); 542 # else 509 543 free(ptr); 544 # endif 510 545 #endif 511 546 }
Note:
See TracChangeset
for help on using the changeset viewer.