Back to index

radiance  4R0+20100331
Defines | Functions | Variables
palloc.c File Reference
#include "meta.h"
#include "rtio.h"

Go to the source code of this file.

Defines

#define FBSIZE   72 /* size of malloc call */

Functions

static int morefree (void)
PRIMITIVE * palloc (void)
void pfree (register PRIMITIVE *p)
void plfree (register PLIST *pl)

Variables

static const char RCSid [] = "$Id: palloc.c,v 1.4 2003/11/15 02:13:37 schorsch Exp $"
int maxalloc
int nalloc = 0
static PLIST freelist = {NULL, NULL}

Define Documentation

#define FBSIZE   72 /* size of malloc call */

Definition at line 9 of file palloc.c.


Function Documentation

static int morefree ( void  ) [static]

Definition at line 89 of file palloc.c.

{
 register PRIMITIVE  *p;
 register int  i;
 int rnu;

 if (maxalloc > 0 && (i = maxalloc-nalloc) < FBSIZE)
    rnu = i;
 else
    rnu = i = FBSIZE;

 p = (PRIMITIVE *)malloc((unsigned)i * sizeof(PRIMITIVE));

 if (p == NULL)
    return(0);

 while (i--) {
    p->args = NULL;
    push(p, &freelist);
    p++;
    }

 return(rnu);
 }

Here is the call graph for this function:

Here is the caller graph for this function:

PRIMITIVE* palloc ( void  )

Definition at line 26 of file palloc.c.

{
    register PRIMITIVE  *p;

    if (maxalloc > 0 && nalloc >= maxalloc)
       return(NULL);

    if ((p = pop(&freelist)) == NULL) {
       if (morefree())
           p = pop(&freelist);
       else {
           sprintf(errmsg, "out of memory in palloc (nalloc = %d)", nalloc);
           error(SYSTEM, errmsg);
       }
    }

    nalloc++;
    return(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pfree ( register PRIMITIVE *  p)

Definition at line 50 of file palloc.c.

{

 if (p->args != NULL) {
    freestr(p->args);
    p->args = NULL;
    } 
 push(p, &freelist);
 nalloc--;

 }

Here is the call graph for this function:

void plfree ( register PLIST *  pl)

Definition at line 67 of file palloc.c.

{
    register PRIMITIVE  *p;
    
    for (p = pl->ptop; p != NULL; p = p->pnext) {
        if (p->args != NULL) {
           freestr(p->args);
           p->args = NULL;
           }
        nalloc--;
        }

    append(pl, &freelist);
    pl->ptop = pl->pbot = NULL;

}

Here is the call graph for this function:


Variable Documentation

PLIST freelist = {NULL, NULL} [static]

Definition at line 19 of file palloc.c.

int maxalloc

Definition at line 29 of file meta2bmp.c.

int nalloc = 0

Definition at line 17 of file palloc.c.

const char RCSid[] = "$Id: palloc.c,v 1.4 2003/11/15 02:13:37 schorsch Exp $" [static]

Definition at line 2 of file palloc.c.