VirtualBox

忽略:
時間撮記:
2010-7-30 下午08:02:05 (14 年 以前)
作者:
vboxsync
訊息:

xpcom: Use RTMem* for memory alloc so that we can more easily wrap direct it to the electric fence heap.

位置:
trunk/src/libs/xpcom18a4/nsprpub
檔案:
修改 5 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/libs/xpcom18a4/nsprpub/lib/libc/src/strdup.c

    r1 r31259  
    3939#include "prmem.h"
    4040#include <string.h>
     41#ifdef VBOX_USE_IPRT_IN_NSPR
     42#include <iprt/mem.h>
     43#endif
    4144
    4245PR_IMPLEMENT(char *)
     
    5154    n = strlen(s) + 1;
    5255
     56#ifdef VBOX_USE_IPRT_IN_NSPR
     57    rv = (char *)RTMemAlloc(n);
     58#else
    5359    rv = (char *)malloc(n);
     60#endif
    5461    if( (char *)0 == rv ) return rv;
    5562
     
    6269PL_strfree(char *s)
    6370{
     71#ifdef VBOX_USE_IPRT_IN_NSPR
     72    RTMemFree(s);
     73#else
    6474    free(s);
     75#endif
    6576}
    6677
     
    7687    l = PL_strnlen(s, max);
    7788
     89#ifdef VBOX_USE_IPRT_IN_NSPR
     90    rv = (char *)RTMemAlloc(l+1);
     91#else
    7892    rv = (char *)malloc(l+1);
     93#endif
    7994    if( (char *)0 == rv ) return rv;
    8095
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prlog.c

    r11858 r31259  
    5151
    5252#if defined(VBOX) && defined(DEBUG)
    53 #include <iprt/initterm.h> /* for RTR3Init */
    54 #include <iprt/log.h>
     53# include <iprt/initterm.h> /* for RTR3Init */
     54# include <iprt/log.h>
     55#endif
     56#ifdef VBOX_USE_IPRT_IN_NSPR
     57# include <iprt/string.h>
    5558#endif
    5659
     
    337340    while (lm != NULL) {
    338341        PRLogModuleInfo *next = lm->next;
     342#ifdef VBOX_USE_IPRT_IN_NSPR
     343        RTStrFree((/*const*/ char *)lm->name);
     344#else
    339345        free((/*const*/ char *)lm->name);
     346#endif
    340347        PR_Free(lm);
    341348        lm = next;
     
    395402    lm = PR_NEWZAP(PRLogModuleInfo);
    396403    if (lm) {
     404#ifdef VBOX_USE_IPRT_IN_NSPR
     405        lm->name = RTStrDup(name);
     406#else
    397407        lm->name = strdup(name);
     408#endif
    398409        lm->level = PR_LOG_NONE;
    399410        lm->next = logModules;
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/linking/prlink.c

    r16397 r31259  
    113113
    114114#endif /* !VBOX_USE_MORE_IPRT_IN_NSPR */
     115#ifdef VBOX_USE_IPRT_IN_NSPR
     116# include <iprt/mem.h>
     117# include <iprt/string.h>
     118# undef  strdup
     119# define strdup(str) RTStrDup(str)
     120#endif
    115121
    116122#define _PR_DEFAULT_LD_FLAGS PR_LD_LAZY
     
    418424
    419425    if (_pr_currentLibPath) {
     426#ifdef VBOX_USE_IPRT_IN_NSPR
     427        RTStrFree(_pr_currentLibPath);
     428#else
    420429        free(_pr_currentLibPath);
     430#endif
    421431        _pr_currentLibPath = NULL;
    422432    }
     
    437447    PR_EnterMonitor(pr_linker_lock);
    438448    if (_pr_currentLibPath) {
     449#ifdef VBOX_USE_IPRT_IN_NSPR
     450        RTStrFree(_pr_currentLibPath);
     451#else
    439452        free(_pr_currentLibPath);
     453#endif
    440454    }
    441455    if (path) {
     
    488502
    489503    len = strlen(ev) + 1;        /* +1 for the null */
     504# ifdef VBOX_USE_IPRT_IN_NSPR
     505    p = (char*) RTStrAlloc(len);
     506# else
    490507    p = (char*) malloc(len);
     508# endif
    491509    if (p) {
    492510        strcpy(p, ev);
     
    519537    len = strlen(ev) + 1;        /* +1 for the null */
    520538
     539# ifdef VBOX_USE_IPRT_IN_NSPR
     540    p = (char*) RTStrAlloc(len);
     541# else
    521542    p = (char*) malloc(len);
     543# endif
    522544    if (p) {
    523545        strcpy(p, ev);
     
    530552    /* AFAIK there isn't a library path with the HP SHL interface --Rob */
    531553    ev = strdup("");
    532 #endif
     554# endif
    533555#endif
    534556
     
    540562  exit:
    541563    if (_pr_currentLibPath) {
     564#ifdef VBOX_USE_IPRT_IN_NSPR
     565        copy = RTMemDup(_pr_currentLibPath, strlen(_pr_currentLibPath) + 1);
     566#else
    542567        copy = strdup(_pr_currentLibPath);
     568#endif
    543569    }
    544570    PR_ExitMonitor(pr_linker_lock);
     
    14751501  freeLib:
    14761502    PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Unloaded library %s", lib->name));
     1503#ifdef VBOX_USE_IPRT_IN_NSPR
     1504    RTStrFree(lib->name);
     1505#else
    14771506    free(lib->name);
     1507#endif
    14781508    lib->name = NULL;
    14791509    PR_DELETE(lib);
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/malloc/prmem.c

    r31253 r31259  
    4141
    4242#include "primpl.h"
    43 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     43#ifdef VBOX_USE_IPRT_IN_NSPR
    4444# include <iprt/mem.h>
    4545#endif
     
    108108                MemBlockHdr *hdr = mz->head;
    109109                mz->head = hdr->s.next;  /* unlink it */
     110#ifdef VBOX_USE_IPRT_IN_NSPR
     111                RTMemFree(hdr);
     112#else
    110113                free(hdr);
     114#endif
    111115                mz->elements--;
    112116            }
     
    281285        pthread_mutex_unlock(&mz->lock);
    282286
     287#ifdef VBOX_USE_IPRT_IN_NSPR
     288        mb = (MemBlockHdr *)RTMemAlloc(blockSize + 2 * (sizeof *mb));
     289#else
    283290        mb = (MemBlockHdr *)malloc(blockSize + 2 * (sizeof *mb));
     291#endif
    284292        if (!mb) {
    285293            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     
    301309    /* size was too big.  Create a block with no zone */
    302310    blockSize = (size & 15) ? size + 16 - (size & 15) : size;
     311#ifdef VBOX_USE_IPRT_IN_NSPR
     312    mb = (MemBlockHdr *)RTMemAlloc(blockSize + 2 * (sizeof *mb));
     313#else
    303314    mb = (MemBlockHdr *)malloc(blockSize + 2 * (sizeof *mb));
     315#endif
    304316    if (!mb) {
    305317        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     
    351363#endif
    352364        /* We don't know how big it is.  But we can fix that. */
     365#ifdef VBOX_USE_IPRT_IN_NSPR
     366        oldptr = RTMemRealloc(oldptr, bytes);
     367#else
    353368        oldptr = realloc(oldptr, bytes);
     369#endif
    354370        if (!oldptr) {
    355371            if (bytes) {
     
    384400            pr_ZoneFree(oldptr);
    385401        else if (oldptr)
     402#ifdef VBOX_USE_IPRT_IN_NSPR
     403            RTMemFree(oldptr);
     404#else
    386405            free(oldptr);
     406#endif
    387407    }
    388408    return rv;
     
    408428            "Warning: freeing memory block %p from ordinary malloc\n", ptr);
    409429#endif
     430#ifdef VBOX_USE_IPRT_IN_NSPR
     431        RTMemFree(ptr);
     432#else
    410433        free(ptr);
     434#endif
    411435        return;
    412436    }
     
    421445        PR_ASSERT(blockSize > 65536);
    422446        /* This block was not in any zone.  Just free it. */
     447#ifdef VBOX_USE_IPRT_IN_NSPR
     448        RTMemFree(mb);
     449#else
    423450        free(mb);
     451#endif
    424452        return;
    425453    }
     
    441469    if (!_pr_initialized) _PR_ImplicitInitialization();
    442470
    443 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     471#ifdef VBOX_USE_IPRT_IN_NSPR
    444472    return use_zone_allocator ? pr_ZoneMalloc(size) : RTMemAlloc(size);
    445473#else
     
    453481
    454482    return use_zone_allocator ?
    455 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     483#ifdef VBOX_USE_IPRT_IN_NSPR
    456484        pr_ZoneCalloc(nelem, elsize) : RTMemAllocZ(nelem * (size_t)elsize);
    457485#else
     
    464492    if (!_pr_initialized) _PR_ImplicitInitialization();
    465493
    466 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     494#ifdef VBOX_USE_IPRT_IN_NSPR
    467495    return use_zone_allocator ? pr_ZoneRealloc(ptr, size) : RTMemRealloc(ptr, size);
    468496#else
     
    476504        pr_ZoneFree(ptr);
    477505    else
    478 #ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     506#ifdef VBOX_USE_IPRT_IN_NSPR
    479507        RTMemFree(ptr);
    480508#else
     
    498526    return PR_MD_malloc( (size_t) size);
    499527#else
    500 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     528# ifdef VBOX_USE_IPRT_IN_NSPR
    501529    return RTMemAlloc(size);
    502530# else
     
    512540
    513541#else
    514 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     542# ifdef VBOX_USE_IPRT_IN_NSPR
    515543    return RTMemAllocZ(nelem * (size_t)elsize);
    516544# else
     
    525553    return PR_MD_realloc( ptr, (size_t) size);
    526554#else
    527 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     555# ifdef VBOX_USE_IPRT_IN_NSPR
    528556    return RTMemRealloc(ptr, size);
    529557# else
     
    538566    PR_MD_free( ptr );
    539567#else
    540 # ifdef VBOX_USE_MORE_IPRT_IN_NSPR
     568# ifdef VBOX_USE_IPRT_IN_NSPR
    541569    RTMemFree(ptr);
    542570# else
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prdtoa.c

    r1 r31259  
    267267#endif
    268268#else
     269# ifdef VBOX_USE_IPRT_IN_NSPR
     270#  include <iprt/mem.h>
     271#  define MALLOC RTMemAlloc
     272# else
    269273#define MALLOC malloc
     274# endif
    270275#endif
    271276
     
    34193424    }
    34203425    freedtoa(result);
    3421     return rv; 
     3426    return rv;
    34223427}
    34233428
     
    34273432** point value.
    34283433** This should be reparameterized so that you can send in a
    3429 **   prcn for the positive and negative ranges.  For now, 
     3434**   prcn for the positive and negative ranges.  For now,
    34303435**   conform to the ECMA JavaScript spec which says numbers
    34313436**   less than 1e-6 are in scientific notation.
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette