*** empty log message ***

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@1011 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2001-01-30 17:06:16 +00:00
commit bb2b81dc43
9 changed files with 296 additions and 329 deletions

View file

@ -23,6 +23,7 @@ typedef struct _WadMemory {
} WadMemory;
static WadMemory *current = 0; /* Current memory block */
static WadMemory *persistent = 0; /* Persistent memory data */
static int pagesize = 0; /* System page size */
static int devzero = 0;
@ -92,6 +93,7 @@ void *wad_malloc(int nbytes) {
/* Yep. Found a region */
break;
}
wm = wm->next;
}
if (!wm) {
wad_printf("wad_malloc: new page\n", nbytes);
@ -107,6 +109,24 @@ void *wad_malloc(int nbytes) {
return c;
}
/* -----------------------------------------------------------------------------
* wad_pmalloc()
*
* Persistent memory allocation. Allocates memory that will never be reclaimed.
* This is only really used to store information pertaining to object files.
* ----------------------------------------------------------------------------- */
void *wad_pmalloc(int nbytes) {
void *ptr;
WadMemory *tmp;
tmp = current;
current = persistent;
ptr = wad_malloc(nbytes);
persistent = current;
current = tmp;
return ptr;
}
/* -----------------------------------------------------------------------------
* wad_release_memory()
*
@ -119,7 +139,7 @@ void wad_release_memory() {
wm = current;
while (wm) {
next = wm->next;
munmap(wm, wm->npages*pagesize);
munmap((char *) wm, wm->npages*pagesize);
wm = next;
}
current = 0;
@ -139,3 +159,11 @@ char *wad_strdup(const char *c) {
return t;
}
char *wad_pstrdup(const char *c) {
char *t;
if (!c) c = "";
t = (char *) wad_pmalloc(strlen(c)+1);
strcpy(t,c);
return t;
}