Exemplo n.º 1
0
/* # 83 "../../../mozilla/nsprpub/lib/ds/plarena.c" */
static PRStatus InitializeArenas( void )
{
    ((arenaLock == ((void *)0))?((void)0):PR_Assert("arenaLock == NULL","../../../mozilla/nsprpub/lib/ds/plarena.c",85));
    arenaLock = PR_NewLock();
    if ( arenaLock == ((void *)0) )
        return PR_FAILURE;
    else
        return PR_SUCCESS;
}
Exemplo n.º 2
0
static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
{
    PLArena **ap, *a;

    ap = &head->next;
    a = *ap;
    if (!a)
        return;


    do {
        ((a->base <= a->avail && a->avail <= a->limit)?((void)0):PR_Assert("a->base <= a->avail && a->avail <= a->limit","../../../mozilla/nsprpub/lib/ds/plarena.c",274));
        a->avail = a->base;
        ((((a)->avail <= (a)->limit)?((void)0):PR_Assert("(a)->avail <= (a)->limit","../../../mozilla/nsprpub/lib/ds/plarena.c",276)), memset((void*)(a)->avail, 0xDA, (a)->limit - (a)->avail));
    } while ((a = a->next) != 0);
    a = *ap;


    if (reallyFree) {
        do {
            *ap = a->next;
            memset((void*)(a), 0xDA, (a)->limit - (PRUword)(a));
            ;
            { PR_Free(a); (a) = ((void *)0); };
        } while ((a = *ap) != 0);
    } else {

        do {
            ap = &(*ap)->next;
        } while (*ap);
        LockArena();
        *ap = arena_freelist;
        arena_freelist = a;
        head->next = 0;
        UnlockArena();
    }

    pool->current = head;
}
Exemplo n.º 3
0
PL_strlen(const char *str)
{
    size_t l;

    if( (const char *)0 == str ) return 0;

    l = strlen(str);

    /* error checking in case we have a 64-bit platform -- make sure
     * we don't have ultra long strings that overflow an int32
     */ 
    if( sizeof(PRUint32) < sizeof(size_t) )
    {
        if( l > PR_INT32_MAX )
            PR_Assert("l <= PR_INT32_MAX", __FILE__, __LINE__);
    }

    return (PRUint32)l;
}
Exemplo n.º 4
0
/* # 168 "../../../mozilla/nsprpub/lib/ds/plarena.c" */
__attribute__((visibility("default"))) void * PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
{
    PLArena *a;
    char *rp;

    (((nb & pool->mask) == 0)?((void)0):PR_Assert("(nb & pool->mask) == 0","../../../mozilla/nsprpub/lib/ds/plarena.c",173));

    nb = (PRUword)(((PRUword)(nb) + (pool)->mask) & ~(pool)->mask);


    {
        a = pool->current;
        do {
            if ( a->avail +nb <= a->limit ) {
                pool->current = a;
                rp = (char *)a->avail;
                a->avail += nb;
                return rp;
            }
        } while( ((void *)0) != (a = a->next) );
    }


    {
        PLArena *p;


        if ( PR_FAILURE == LockArena())
            return(0);

        for ( a = arena_freelist, p = ((void *)0); a != ((void *)0) ; p = a, a = a->next ) {
            if ( a->base +nb <= a->limit ) {
                if ( p == ((void *)0) )
                    arena_freelist = a->next;
                else
                    p->next = a->next;
                UnlockArena();
                a->avail = a->base;
                rp = (char *)a->avail;
                a->avail += nb;


                a->next = pool->current->next;
                pool->current->next = a;
                pool->current = a;
                if ( ((void *)0) == pool->first.next )
                    pool->first.next = a;
                return(rp);
            }
        }
        UnlockArena();
    }


    {
        PRUint32 sz = ((pool->arenasize)>(nb)?(pool->arenasize):(nb));
        sz += sizeof *a + pool->mask;
        a = (PLArena*)(PR_Malloc((sz)));
        if ( ((void *)0) != a ) {
            a->limit = (PRUword)a + sz;
            a->base = a->avail = (PRUword)(((PRUword)(a + 1) + (pool)->mask) /*& ~(pool)->mask*/);
            rp = (char *)a->avail;
            a->avail += nb;


            a->next = pool->current->next;
            pool->current->next = a;
            pool->current = a;
            if ( ((void *)0) == pool->first.next )
                pool->first.next = a;
            ;
            ;
            return(rp);
        }
    }


    return(((void *)0));
}
static void _MY_Assert(const char *s, const char *file, PRIntn ln)
{
    PL_PrintError(NULL);
    PR_Assert(s, file, ln);
}  /* _MY_Assert */