The functions definitions in vmalloc are all surrounded by an `#if __STD_C`, if __STD_C is not defined than the old style function definition is used. These days STD C is the standard and the old style function defintions are obsolete.
They have been removed from lib/vmalloc and its subprojects, comments have been preserved by converting them to a Doxygen style.
#undef memalign
#undef valloc
-#if __STD_C
static Vmulong_t atou(char **sp)
-#else
-static Vmulong_t atou(sp)
-char **sp;
-#endif
{
char *s = *sp;
Vmulong_t v = 0;
vmdbcheck(Vmregion); \
}
-#if __STD_C
static char *insertpid(char *begs, char *ends)
-#else
-static char *insertpid(begs, ends)
-char *begs;
-char *ends;
-#endif
{
int pid;
char *s;
return begs;
}
-#if __STD_C
static int createfile(char *file)
-#else
-static int createfile(file)
-char *file;
-#endif
{
char buf[1024];
char *next, *endb;
#endif
}
-#if __STD_C
static void pfprint(void)
-#else
-static void pfprint()
-#endif
{
if (Vmregion->meth.meth == VM_MTPROFILE)
vmprofile(Vmregion, _Vmpffd);
}
-#if __STD_C
static int vmflinit(void)
-#else
-static int vmflinit()
-#endif
{
char *env;
Vmalloc_t *vm;
return 0;
}
-#if __STD_C
Void_t *malloc(reg size_t size)
-#else
-Void_t *malloc(size)
-reg size_t size;
-#endif
{
VMFLINIT();
return (*Vmregion->meth.allocf) (Vmregion, size);
}
-#if __STD_C
+/**
+ * @param data block to be reallocated
+ * @param size new size
+ */
Void_t *realloc(reg Void_t * data, reg size_t size)
-#else
-Void_t *realloc(data, size)
-reg Void_t *data; /* block to be reallocated */
-reg size_t size; /* new size */
-#endif
{
VMFLINIT();
return (*Vmregion->meth.resizef) (Vmregion, data, size,
VM_RSCOPY | VM_RSMOVE);
}
-#if __STD_C
void free(reg Void_t * data)
-#else
-void free(data)
-reg Void_t *data;
-#endif
{
VMFLINIT();
(void) (*Vmregion->meth.freef) (Vmregion, data);
}
-#if __STD_C
Void_t *calloc(reg size_t n_obj, reg size_t s_obj)
-#else
-Void_t *calloc(n_obj, s_obj)
-reg size_t n_obj;
-reg size_t s_obj;
-#endif
{
VMFLINIT();
return (*Vmregion->meth.resizef) (Vmregion, NIL(Void_t *),
n_obj * s_obj, VM_RSZERO);
}
-#if __STD_C
void cfree(reg Void_t * data)
-#else
-void cfree(data)
-reg Void_t *data;
-#endif
{
VMFLINIT();
(void) (*Vmregion->meth.freef) (Vmregion, data);
}
-#if __STD_C
Void_t *memalign(reg size_t align, reg size_t size)
-#else
-Void_t *memalign(align, size)
-reg size_t align;
-reg size_t size;
-#endif
{
VMFLINIT();
return (*Vmregion->meth.alignf) (Vmregion, size, align);
}
-#if __STD_C
Void_t *valloc(reg size_t size)
-#else
-Void_t *valloc(size)
-reg size_t size;
-#endif
{
VMFLINIT();
GETPAGESIZE(_Vmpagesize);
#undef alloca
#if _lib_mallopt
-#if __STD_C
int mallopt(int cmd, int value)
-#else
-int mallopt(cmd, value)
-int cmd;
-int value;
-#endif
{
VMFLINIT();
return 0;
#endif
#if _lib_mallinfo
-#if __STD_C
struct mallinfo mallinfo(void)
-#else
-struct mallinfo mallinfo()
-#endif
{
Vmstat_t sb;
struct mallinfo mi;
#endif
#if _lib_mstats
-#if __STD_C
struct mstats mstats(void)
-#else
-struct mstats mstats()
-#endif
{
Vmstat_t sb;
struct mstats ms;
Vmuchar_t data[1];
};
-#if __STD_C
Void_t *alloca(size_t size)
-#else
-Void_t *alloca(size)
-size_t size;
-#endif
{
char array[ALIGN];
char *file;
static int Vmcheck = 0; /* 1 if checking */
/* Check to see if a block is in the free tree */
-#if __STD_C
static int vmintree(Block_t * node, Block_t * b)
-#else
-static int vmintree(node, b)
-Block_t *node;
-Block_t *b;
-#endif
{
Block_t *t;
}
/* Check to see if a block is known to be free */
-#if __STD_C
static int vmisfree(Vmdata_t * vd, Block_t * b)
-#else
-static int vmisfree(vd, b)
-Vmdata_t *vd;
-Block_t *b;
-#endif
{
Block_t *t;
size_t s;
}
/* check to see if the tree is in good shape */
-#if __STD_C
static int vmchktree(Block_t * node)
-#else
-static int vmchktree(node)
-Block_t *node;
-#endif
{
Block_t *t;
return 1;
}
-#if __STD_C
static int vmonlist(Block_t * list, Block_t * b)
-#else
-static int vmonlist(list, b)
-Block_t *list;
-Block_t *b;
-#endif
{
for (; list; list = LINK(list))
if (list == b)
return 0;
}
-#if __STD_C
+/**
+ * @param vd
+ * @param size if > 0, checking that no large free block >size
+ * @param wild if != 0, do above but allow wild to be >size
+ */
static int vmcheck(Vmdata_t * vd, size_t size, int wild)
-#else
-static int vmcheck(vd, size, wild)
-Vmdata_t *vd;
-size_t size; /* if > 0, checking that no large free block >size */
-int wild; /* if != 0, do above but allow wild to be >size */
-#endif
{
reg Seg_t *seg;
reg Block_t *b, *endb, *t, *np;
#define RLINK(s,x) ((s) = LEFT(s) = (x))
#define LLINK(s,x) ((s) = RIGHT(s) = (x))
/* Find and delete a suitable element in the free tree. */
-#if __STD_C
static Block_t *bestsearch(Vmdata_t * vd, reg size_t size,
Block_t * wanted)
-#else
-static Block_t *bestsearch(vd, size, wanted)
-Vmdata_t *vd;
-reg size_t size;
-Block_t *wanted;
-#endif
{
reg size_t s;
reg Block_t *t, *root, *l, *r;
}
/* Reclaim all delayed free blocks into the free tree */
-#if __STD_C
static int bestreclaim(reg Vmdata_t * vd, Block_t * wanted, int c)
-#else
-static int bestreclaim(vd, wanted, c)
-reg Vmdata_t *vd;
-Block_t *wanted;
-int c;
-#endif
{
reg size_t size, s;
reg Block_t *fp, *np, *t, *list, **cache;
return count;
}
-#if __STD_C
+/**
+ * @param vm region allocating from
+ * @param size desired block size
+ */
static Void_t *bestalloc(Vmalloc_t * vm, reg size_t size)
-#else
-static Void_t *bestalloc(vm, size)
-Vmalloc_t *vm; /* region allocating from */
-reg size_t size; /* desired block size */
-#endif
{
reg Vmdata_t *vd = vm->data;
reg size_t s;
return DATA(tp);
}
-#if __STD_C
+/**
+ * @param vm region allocating from
+ * @param addr address to check
+ */
static long bestaddr(Vmalloc_t * vm, Void_t * addr)
-#else
-static long bestaddr(vm, addr)
-Vmalloc_t *vm; /* region allocating from */
-Void_t *addr; /* address to check */
-#endif
{
reg Seg_t *seg;
reg Block_t *b, *endb;
return offset;
}
-#if __STD_C
static int bestfree(Vmalloc_t * vm, Void_t * data)
-#else
-static int bestfree(vm, data)
-Vmalloc_t *vm;
-Void_t *data;
-#endif
{
reg Vmdata_t *vd = vm->data;
reg Block_t *bp, **cache;
return 0;
}
-#if __STD_C
+/**
+ * @param vm region allocation from
+ * @param data old block of data
+ * @param size new size
+ * @param type !=0 to move, <0 for not copy
+ */
static Void_t *bestresize(Vmalloc_t * vm, Void_t * data, reg size_t size,
int type)
-#else
-static Void_t *bestresize(vm, data, size, type)
-Vmalloc_t *vm; /* region allocating from */
-Void_t *data; /* old block of data */
-reg size_t size; /* new size */
-int type; /* !=0 to move, <0 for not copy */
-#endif
{
reg Vmdata_t *vd = vm->data;
reg Block_t *rp, *np, *t, **cache;
return data;
}
-#if __STD_C
+/**
+ * @param vm region allocating from
+ * @param addr address to check
+ */
static long bestsize(Vmalloc_t * vm, Void_t * addr)
-#else
-static long bestsize(vm, addr)
-Vmalloc_t *vm; /* region allocating from */
-Void_t *addr; /* address to check */
-#endif
{
reg Seg_t *seg;
reg Block_t *b, *endb;
return size;
}
-#if __STD_C
static int bestcompact(Vmalloc_t * vm)
-#else
-static int bestcompact(vm)
-Vmalloc_t *vm;
-#endif
{
reg Seg_t *seg, *next;
reg Block_t *bp, *t;
return 0;
}
-#if __STD_C
static Void_t *bestalign(Vmalloc_t * vm, size_t size, size_t align)
-#else
-static Void_t *bestalign(vm, size, align)
-Vmalloc_t *vm;
-size_t size;
-size_t align;
-#endif
{
reg Vmuchar_t *data;
reg Block_t *tp, *np;
}
/* A discipline to get memory using sbrk() or VirtualAlloc on win32 */
-#if __STD_C
+/**
+ * @param vm region doing allocation from
+ * @param caddr current address
+ * @param csize current size
+ * @param nsize new size
+ * @param disc discipline structure
+ */
static Void_t *sbrkmem(Vmalloc_t * vm, Void_t * caddr,
size_t csize, size_t nsize, Vmdisc_t * disc)
-#else
-static Void_t *sbrkmem(vm, caddr, csize, nsize, disc)
-Vmalloc_t *vm; /* region doing allocation from */
-Void_t *caddr; /* current address */
-size_t csize; /* current size */
-size_t nsize; /* new size */
-Vmdisc_t *disc; /* discipline structure */
-#endif
{
#if _std_malloc || _BLD_INSTRUMENT || cray
NOTUSED(vm);
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
int vmclear(Vmalloc_t * vm)
-#else
-int vmclear(vm)
-Vmalloc_t *vm;
-#endif
{
reg Seg_t *seg;
reg Seg_t *next;
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
int vmclose(Vmalloc_t * vm)
-#else
-int vmclose(vm)
-Vmalloc_t *vm;
-#endif
{
reg Seg_t *seg, *vmseg;
reg Vmemory_f memoryf;
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
+/**
+ * @param vm region doing allocation from
+ * @param caddr current low address
+ * @param csize current size
+ * @param nsize new size
+ * @param disc discipline structure
+ */
static Void_t *heapmem(Vmalloc_t * vm, Void_t * caddr,
size_t csize, size_t nsize, Vmdisc_t * disc)
-#else
-static Void_t *heapmem(vm, caddr, csize, nsize, disc)
-Vmalloc_t *vm; /* region doing allocation from */
-Void_t *caddr; /* current low address */
-size_t csize; /* current size */
-size_t nsize; /* new size */
-Vmdisc_t *disc; /* discipline structure */
-#endif
{
NOTUSED(vm);
NOTUSED(disc);
}
/* just an entry point to make it easy to set break point */
-#if __STD_C
static void vmdbwarn(Vmalloc_t * vm, char *mesg, int n)
-#else
-static void vmdbwarn(vm, mesg, n)
-Vmalloc_t *vm;
-char *mesg;
-int n;
-#endif
{
reg Vmdata_t *vd = vm->data;
}
/* issue a warning of some type */
-#if __STD_C
+/**
+ * @param vm region holding the block
+ * @param data data block
+ * @param where byte that was corrupted
+ * @param file file where call originates
+ * @param line line number of call
+ * @param type operation being done
+ */
static void dbwarn(Vmalloc_t * vm, Void_t * data, int where, char *file,
int line, int type)
-#else
-static void dbwarn(vm, data, where, file, line, type)
-Vmalloc_t *vm; /* region holding the block */
-Void_t *data; /* data block */
-int where; /* byte that was corrupted */
-char *file; /* file where call originates */
-int line; /* line number of call */
-int type; /* operation being done */
-#endif
{
char buf[1024], *bufp, *endbuf, *s;
#define SLOP 64 /* enough for a message and an int */
}
/* check for watched address and issue warnings */
-#if __STD_C
static void dbwatch(Vmalloc_t * vm, Void_t * data, char *file, int line,
int type)
-#else
-static void dbwatch(vm, data, file, line, type)
-Vmalloc_t *vm;
-Void_t *data;
-char *file;
-int line;
-int type;
-#endif
{
reg int n;
}
/* record information about the block */
-#if __STD_C
+/**
+ * @param data real address not the one from Vmbest
+ * @param size the actual requested size
+ * @param file file where the request came from
+ * @param line and line number
+ */
static void dbsetinfo(Vmuchar_t * data, size_t size, char *file, int line)
-#else
-static void dbsetinfo(data, size, file, line)
-Vmuchar_t *data; /* real address not the one from Vmbest */
-size_t size; /* the actual requested size */
-char *file; /* file where the request came from */
-int line; /* and line number */
-#endif
{
reg Vmuchar_t *begp, *endp;
reg Dbfile_t *last, *db;
** This returns -(offset+1) if block is already freed, +(offset+1)
** if block is live, 0 if no match.
*/
-#if __STD_C
static long dbaddr(Vmalloc_t * vm, Void_t * addr)
-#else
-static long dbaddr(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
reg Block_t *b = NULL, *endb = NULL;
reg Seg_t *seg;
}
-#if __STD_C
static long dbsize(Vmalloc_t * vm, Void_t * addr)
-#else
-static long dbsize(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
reg Block_t *b, *endb;
reg Seg_t *seg;
return size;
}
-#if __STD_C
static Void_t *dballoc(Vmalloc_t * vm, size_t size)
-#else
-static Void_t *dballoc(vm, size)
-Vmalloc_t *vm;
-size_t size;
-#endif
{
reg size_t s;
reg Vmuchar_t *data;
}
-#if __STD_C
static int dbfree(Vmalloc_t * vm, Void_t * data)
-#else
-static int dbfree(vm, data)
-Vmalloc_t *vm;
-Void_t *data;
-#endif
{
char *file;
int line;
}
/* Resizing an existing block */
-#if __STD_C
+/**
+ * @param vm region allocating from
+ * @param addr old block of data
+ * @param size new size
+ * @param type !=0 for movable, >0 for copy
+ */
static Void_t *dbresize(Vmalloc_t * vm, Void_t * addr, reg size_t size,
int type)
-#else
-static Void_t *dbresize(vm, addr, size, type)
-Vmalloc_t *vm; /* region allocating from */
-Void_t *addr; /* old block of data */
-reg size_t size; /* new size */
-int type; /* !=0 for movable, >0 for copy */
-#endif
{
reg Vmuchar_t *data;
reg size_t s, oldsize;
}
/* compact any residual free space */
-#if __STD_C
static int dbcompact(Vmalloc_t * vm)
-#else
-static int dbcompact(vm)
-Vmalloc_t *vm;
-#endif
{
return (*(Vmbest->compactf)) (vm);
}
/* check for memory overwrites over all live blocks */
-#if __STD_C
int vmdbcheck(Vmalloc_t * vm)
-#else
-int vmdbcheck(vm)
-Vmalloc_t *vm;
-#endif
{
reg Block_t *b, *endb;
reg Seg_t *seg;
}
/* set/delete an address to watch */
-#if __STD_C
+/**
+ * set/delete an address to watch
+ *
+ * @param addr address to insert
+ */
Void_t *vmdbwatch(Void_t * addr)
-#else
-Void_t *vmdbwatch(addr)
-Void_t *addr; /* address to insert */
-#endif
{
reg int n;
reg Void_t *out;
return out;
}
-#if __STD_C
static Void_t *dbalign(Vmalloc_t * vm, size_t size, size_t align)
-#else
-static Void_t *dbalign(vm, size, align)
-Vmalloc_t *vm;
-size_t size;
-size_t align;
-#endif
{
reg Vmuchar_t *data;
reg size_t s;
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
Vmdisc_t *vmdisc(Vmalloc_t * vm, Vmdisc_t * disc)
-#else
-Vmdisc_t *vmdisc(vm, disc)
-Vmalloc_t *vm;
-Vmdisc_t *disc;
-#endif
{
Vmdisc_t *old = vm->disc;
#if _lib_onexit
-#if __STD_C
int atexit(void (*exitf) (void))
-#else
-int atexit(exitf)
-void (*exitf) ();
-#endif
{
return onexit(exitf);
}
} Exit_t;
static Exit_t *Exit;
-#if __STD_C
atexit(void (*exitf) (void))
-#else
-atexit(exitf)
-void (*exitf) ();
-#endif
{
Exit_t *e;
return 0;
}
-#if __STD_C
void exit(int type)
-#else
-void exit(type)
-int type;
-#endif
{
Exit_t *e;
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
static Void_t *lastalloc(Vmalloc_t * vm, size_t size)
-#else
-static Void_t *lastalloc(vm, size)
-Vmalloc_t *vm;
-size_t size;
-#endif
{
reg Block_t *tp, *next;
reg Seg_t *seg, *last;
return (Void_t *) tp;
}
-#if __STD_C
static int lastfree(Vmalloc_t * vm, reg Void_t * data)
-#else
-static int lastfree(vm, data)
-Vmalloc_t *vm;
-reg Void_t *data;
-#endif
{
reg Seg_t *seg;
reg Block_t *fp;
return 0;
}
-#if __STD_C
static Void_t *lastresize(Vmalloc_t * vm, reg Void_t * data, size_t size,
int type)
-#else
-static Void_t *lastresize(vm, data, size, type)
-Vmalloc_t *vm;
-reg Void_t *data;
-size_t size;
-int type;
-#endif
{
reg Block_t *tp;
reg Seg_t *seg;
}
-#if __STD_C
static long lastaddr(Vmalloc_t * vm, Void_t * addr)
-#else
-static long lastaddr(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
reg Vmdata_t *vd = vm->data;
return (Vmuchar_t *) addr - (Vmuchar_t *) vd->free;
}
-#if __STD_C
static long lastsize(Vmalloc_t * vm, Void_t * addr)
-#else
-static long lastsize(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
reg Vmdata_t *vd = vm->data;
sizeof(Head_t);
}
-#if __STD_C
static int lastcompact(Vmalloc_t * vm)
-#else
-static int lastcompact(vm)
-Vmalloc_t *vm;
-#endif
{
reg Block_t *fp;
reg Seg_t *seg, *next;
return 0;
}
-#if __STD_C
static Void_t *lastalign(Vmalloc_t * vm, size_t size, size_t align)
-#else
-static Void_t *lastalign(vm, size, align)
-Vmalloc_t *vm;
-size_t size;
-size_t align;
-#endif
{
reg Vmuchar_t *data;
reg size_t s, orgsize = 0, orgalign = 0;
char a[3 * ALIGN]; /* extra to fuss with alignment */
} Vminit_t;
-#if __STD_C
+/**
+ * @param disc discipline to get segments
+ * @param meth method to manage space
+ * @param mode type of region
+ */
Vmalloc_t *vmopen(Vmdisc_t * disc, Vmethod_t * meth, int mode)
-#else
-Vmalloc_t *vmopen(disc, meth, mode)
-Vmdisc_t *disc; /* discipline to get segments */
-Vmethod_t *meth; /* method to manage space */
-int mode; /* type of region */
-#endif
{
reg Vmalloc_t *vm;
reg Vmdata_t *vd;
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
static Void_t *poolalloc(Vmalloc_t * vm, reg size_t size)
-#else
-static Void_t *poolalloc(vm, size)
-Vmalloc_t *vm;
-reg size_t size;
-#endif
{
reg Vmdata_t *vd = vm->data;
reg Block_t *tp, *next;
return (Void_t *) tp;
}
-#if __STD_C
static long pooladdr(Vmalloc_t * vm, reg Void_t * addr)
-#else
-static long pooladdr(vm, addr)
-Vmalloc_t *vm;
-reg Void_t *addr;
-#endif
{
reg Block_t *bp, *tp;
reg Vmuchar_t *laddr, *baddr;
return offset;
}
-#if __STD_C
static int poolfree(reg Vmalloc_t * vm, reg Void_t * data)
-#else
-static int poolfree(vm, data)
-reg Vmalloc_t *vm;
-reg Void_t *data;
-#endif
{
reg Block_t *bp;
reg Vmdata_t *vd = vm->data;
return 0;
}
-#if __STD_C
static Void_t *poolresize(Vmalloc_t * vm, Void_t * data, size_t size,
int type)
-#else
-static Void_t *poolresize(vm, data, size, type)
-Vmalloc_t *vm;
-Void_t *data;
-size_t size;
-int type;
-#endif
{
reg Vmdata_t *vd = vm->data;
return data;
}
-#if __STD_C
static long poolsize(Vmalloc_t * vm, Void_t * addr)
-#else
-static long poolsize(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
return pooladdr(vm, addr) == 0 ? (long) vm->data->pool : -1L;
}
-#if __STD_C
static int poolcompact(Vmalloc_t * vm)
-#else
-static int poolcompact(vm)
-Vmalloc_t *vm;
-#endif
{
reg Block_t *fp;
reg Seg_t *seg, *next;
return 0;
}
-#if __STD_C
static Void_t *poolalign(Vmalloc_t * vm, size_t size, size_t align)
-#else
-static Void_t *poolalign(vm, size, align)
-Vmalloc_t *vm;
-size_t size;
-size_t align;
-#endif
{
NOTUSED(vm);
NOTUSED(size);
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-/* Get more memory for a region */
-#if __STD_C
+/**
+ * Get more memory for a region
+ *
+ * @param vm region to increase in size
+ * @param size desired amount of space
+ * @param searchf tree search function
+ */
static Block_t *vmextend(reg Vmalloc_t * vm, size_t size,
Vmsearch_f searchf)
-#else
-static Block_t *vmextend(vm, size, searchf)
-reg Vmalloc_t *vm; /* region to increase in size */
-size_t size; /* desired amount of space */
-Vmsearch_f searchf; /* tree search function */
-#endif
{
reg size_t s;
reg Seg_t *seg;
return bp;
}
-/* Truncate a segment if possible */
-#if __STD_C
+/**
+ * Truncate a segment if possible
+ *
+ * @param vm containing region
+ * @param seg the one to be truncated
+ * @param size amount of free space
+ * @param exact amount given was exact
+ */
static int vmtruncate(Vmalloc_t * vm, Seg_t * seg, size_t size, int exact)
-#else
-static int vmtruncate(vm, seg, size, exact)
-Vmalloc_t *vm; /* containing region */
-Seg_t *seg; /* the one to be truncated */
-size_t size; /* amount of free space */
-int exact; /* amount given was exact */
-#endif
{
reg Void_t *caddr;
reg Seg_t *last;
#define PFTABLE 1019 /* table size */
static Vmalloc_t *Vmpf; /* heap for our own use */
-#if __STD_C
+/**
+ * @param vm region allocating from
+ * @param file the file issuing the allocation request
+ * @param line line number
+ */
static Pfobj_t *pfsearch(Vmalloc_t * vm, char *file, int line)
-#else
-static Pfobj_t *pfsearch(vm, file, line)
-Vmalloc_t *vm; /* region allocating from */
-char *file; /* the file issuing the allocation request */
-int line; /* line number */
-#endif
{
reg Pfobj_t *pf, *last;
reg Vmulong_t h;
return pf;
}
-#if __STD_C
static void pfclose(Vmalloc_t * vm)
-#else
-static void pfclose(vm)
-Vmalloc_t *vm;
-#endif
{
reg int n;
reg Pfobj_t *pf, *next, *last;
}
}
-#if __STD_C
static void pfsetinfo(Vmalloc_t * vm, Vmuchar_t * data, size_t size,
char *file, int line)
-#else
-static void pfsetinfo(vm, data, size, file, line)
-Vmalloc_t *vm;
-Vmuchar_t *data;
-size_t size;
-char *file;
-int line;
-#endif
{
reg Pfobj_t *pf;
reg Vmulong_t s;
}
/* sort by file names and line numbers */
-#if __STD_C
static Pfobj_t *pfsort(Pfobj_t * pf)
-#else
-static Pfobj_t *pfsort(pf)
-Pfobj_t *pf;
-#endif
{
reg Pfobj_t *one, *two, *next;
reg int cmp;
}
}
-#if __STD_C
static char *pfsummary(char *buf, Vmulong_t na, Vmulong_t sa,
Vmulong_t nf, Vmulong_t sf, Vmulong_t max,
Vmulong_t size)
-#else
-static char *pfsummary(buf, na, sa, nf, sf, max, size)
-char *buf;
-Vmulong_t na;
-Vmulong_t sa;
-Vmulong_t nf;
-Vmulong_t sf;
-Vmulong_t max;
-Vmulong_t size;
-#endif
{
buf = (*_Vmstrcpy) (buf, "n_alloc", '=');
buf = (*_Vmstrcpy) (buf, (*_Vmitoa) (na, -1), ':');
}
/* print profile data */
-#if __STD_C
int vmprofile(Vmalloc_t * vm, int fd)
-#else
-int vmprofile(vm, fd)
-Vmalloc_t *vm;
-int fd;
-#endif
{
reg Pfobj_t *pf, *list, *next, *last;
reg int n;
return 0;
}
-#if __STD_C
static Void_t *pfalloc(Vmalloc_t * vm, size_t size)
-#else
-static Void_t *pfalloc(vm, size)
-Vmalloc_t *vm;
-size_t size;
-#endif
{
reg size_t s;
reg Void_t *data;
return data;
}
-#if __STD_C
static int pffree(Vmalloc_t * vm, Void_t * data)
-#else
-static int pffree(vm, data)
-Vmalloc_t *vm;
-Void_t *data;
-#endif
{
reg Pfobj_t *pf;
reg size_t s;
return (*(Vmbest->freef)) (vm, data);
}
-#if __STD_C
static Void_t *pfresize(Vmalloc_t * vm, Void_t * data, size_t size,
int type)
-#else
-static Void_t *pfresize(vm, data, size, type)
-Vmalloc_t *vm;
-Void_t *data;
-size_t size;
-int type;
-#endif
{
reg Pfobj_t *pf;
reg size_t s, news;
return addr;
}
-#if __STD_C
static long pfsize(Vmalloc_t * vm, Void_t * addr)
-#else
-static long pfsize(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
return (*Vmbest->addrf) (vm, addr) != 0 ? -1L : (long) PFSIZE(addr);
}
-#if __STD_C
static long pfaddr(Vmalloc_t * vm, Void_t * addr)
-#else
-static long pfaddr(vm, addr)
-Vmalloc_t *vm;
-Void_t *addr;
-#endif
{
return (*Vmbest->addrf) (vm, addr);
}
-#if __STD_C
static int pfcompact(Vmalloc_t * vm)
-#else
-static int pfcompact(vm)
-Vmalloc_t *vm;
-#endif
{
return (*Vmbest->compactf) (vm);
}
-#if __STD_C
static Void_t *pfalign(Vmalloc_t * vm, size_t size, size_t align)
-#else
-static Void_t *pfalign(vm, size, align)
-Vmalloc_t *vm;
-size_t size;
-size_t align;
-#endif
{
reg size_t s;
reg Void_t *data;
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
Vmalloc_t *vmregion(reg Void_t * addr)
-#else
-Vmalloc_t *vmregion(addr)
-reg Void_t *addr;
-#endif
{
return addr ? VM(BLOCK(addr)) : NIL(Vmalloc_t *);
}
** Written by Kiem-Phong Vo, kpv@research.att.com, 02/07/95
*/
-#if __STD_C
+/**
+ * @param vm region
+ * @param addr address
+ */
Void_t *vmsegment(Vmalloc_t * vm, Void_t * addr)
-#else
-Void_t *vmsegment(vm, addr)
-Vmalloc_t *vm; /* region */
-Void_t *addr; /* address */
-#endif
{
reg Seg_t *seg;
reg Vmdata_t *vd = vm->data;
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
+/**
+ * @param vm region being worked on
+ * @param flags flags must be in VM_FLAGS
+ * @param on !=0 if turning on, else turning off
+ */
int vmset(reg Vmalloc_t * vm, int flags, int on)
-#else
-int vmset(vm, flags, on)
-reg Vmalloc_t *vm; /* region being worked on */
-int flags; /* flags must be in VM_FLAGS */
-int on; /* !=0 if turning on, else turning off */
-#endif
{
reg int mode;
reg Vmdata_t *vd = vm->data;
** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
*/
-#if __STD_C
int vmstat(Vmalloc_t * vm, Vmstat_t * st)
-#else
-int vmstat(vm, st)
-Vmalloc_t *vm;
-Vmstat_t *st;
-#endif
{
reg Seg_t *seg;
reg Block_t *b, *endb;
static int Trfile = -1;
static char Trbuf[128];
-#if __STD_C
static char *trstrcpy(char *to, char *from, int endc)
-#else
-static char *trstrcpy(to, from, endc)
-char *to;
-char *from;
-int endc;
-#endif
{
reg int n;
return to;
}
-/* convert a long value to an ascii representation */
-#if __STD_C
+/*
+ * convert a long value to an ascii representation
+ *
+ * @param v value to convert
+ * @param type =0 base-16, >0: unsigned base-10, <0: signed base-10
+ */
static char *tritoa(Vmulong_t v, int type)
-#else
-static char *tritoa(v, type)
-Vmulong_t v; /* value to convert */
-int type; /* =0 base-16, >0: unsigned base-10, <0: signed base-10 */
-#endif
{
char *s;
return s + 1;
}
-/* generate a trace of some call */
-#if __STD_C
+/**
+ * generate a trace of some call
+ * @param vm region call was made from
+ * @param newaddr old data address
+ * @param newaddr new data address
+ * @param size size of piece
+ * @param align alignment
+ */
static void trtrace(Vmalloc_t * vm,
Vmuchar_t * oldaddr, Vmuchar_t * newaddr, size_t size,
size_t align)
-#else
-static void trtrace(vm, oldaddr, newaddr, size, align)
-Vmalloc_t *vm; /* region call was made from */
-Vmuchar_t *oldaddr; /* old data address */
-Vmuchar_t *newaddr; /* new data address */
-size_t size; /* size of piece */
-size_t align; /* alignment */
-#endif
{
char buf[1024], *bufp, *endbuf;
reg Vmdata_t *vd = vm->data;
write(Trfile, buf, (bufp - buf));
}
-#if __STD_C
int vmtrace(int file)
-#else
-int vmtrace(file)
-int file;
-#endif
{
int fd;
return fd;
}
-#if __STD_C
int vmtrbusy(Vmalloc_t * vm)
-#else
-int vmtrbusy(vm)
-Vmalloc_t *vm;
-#endif
{
Seg_t *seg;
Vmdata_t *vd = vm->data;
** Written by Kiem-Phong Vo, kpv@research.att.com (02/08/96)
*/
-#if __STD_C
int vmwalk(Vmalloc_t * vm,
int (*segf) (Vmalloc_t *, Void_t *, size_t, Vmdisc_t *))
-#else
-int vmwalk(vm, segf)
-Vmalloc_t *vm;
-int (*segf) ( /* Vmalloc_t*, Void_t*, size_t, Vmdisc_t* */ );
-#endif
{
reg Seg_t *seg;
reg int rv;