1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
/* @(#) memory.h 1.8 @(#) */
/***************************************************************\
* Copyright (c) 1999 First Step Internet Services, Inc.
* All Rights Reserved
*
* Module: Memory
\***************************************************************/
#ifndef _KOALAMUD_MEMORY_H
#define _KOALAMUD_MEMORY_H "@(#) nitehawk@winghove.1ststep.net|include/memory.h|20001104224529|40562 @(#)"
#include "llist.h"
#include "koalatypes.h"
/* Allocation types */
typedef enum
{
ALLOC_GENERIC = 0, // Memory that will be sticking around for quite a while
ALLOC_DATABASE, // Memory allocated for database purposes
ALLOC_DESCRIPTOR, // Memory allocated to network descriptors
ALLOC_TEMP, // Should stay close to 0
ALLOC_LLIST, // Memory used for linked list
ALLOC_CMDTABLE, // Command table memory
ALLOC_STRING, // Memory used for string storage
/* This entry *MUST* be last */
ALLOC_LISTEND,
} kmalloctype;
/* Memory status struct */
typedef struct
{
size_t allocsize;
int numobjects;
} memstate_t;
extern memstate_t memstate[ALLOC_LISTEND];
listnodeptr getdescriptorlist(void);
pdescriptor allocdescriptor(void);
void freedescriptor(pdescriptor desc);
inline void *kmalloc(size_t len, kmalloctype type);
inline void kmfree(void *ptr, kmalloctype type);
inline void *krealloc(void *ptr, size_t len, kmalloctype type);
void initmemstate(void) __attribute__ ((constructor));
#endif
|