19 |
#ifndef __mem_h |
#ifndef __mem_h |
20 |
#define __mem_h |
#define __mem_h |
21 |
|
|
|
#define MEM_PAGESIZE 4096 |
|
|
#ifndef MINSTRSIZE |
|
|
# define MINSTRSIZE 32 |
|
|
#endif |
|
|
|
|
22 |
typedef unsigned count_t; |
typedef unsigned count_t; |
23 |
typedef double Align_t; |
typedef double Align_t; |
24 |
struct mallocstat { |
struct mallocstat { |
27 |
}; |
}; |
28 |
extern struct mallocstat mallocstat; |
extern struct mallocstat mallocstat; |
29 |
|
|
|
typedef struct { |
|
|
unsigned class_cnt; |
|
|
unsigned bucket_cnt; |
|
|
unsigned bytes_allocated; |
|
|
unsigned bytes_used; |
|
|
} MEM_STAT; |
|
|
|
|
|
typedef struct { |
|
|
int index; |
|
|
int cont; /* Allow contiguous allocation */ |
|
|
size_t elsize; /* Size of an element */ |
|
|
count_t elcnt; /* Number of elements per bucket */ |
|
|
count_t allocated_cnt; /* Number of allocated elements */ |
|
|
count_t bucket_cnt; /* Number of buckets */ |
|
|
} CLASS_STAT; |
|
|
|
|
|
|
|
|
void *mem_alloc(size_t size); |
|
|
void mem_free(void *ptr); |
|
|
void *mem_calloc(count_t count, size_t size); |
|
|
void mem_cfree(void *ptr, count_t count); |
|
|
|
|
30 |
void *radxmalloc(size_t); |
void *radxmalloc(size_t); |
31 |
void *emalloc(size_t); |
void *emalloc(size_t); |
32 |
void *radxrealloc(void *, size_t); |
void *radxrealloc(void *, size_t); |
34 |
void efree(void *); |
void efree(void *); |
35 |
char *estrdup(char *); |
char *estrdup(char *); |
36 |
|
|
|
char *string_alloc(size_t length); |
|
|
char *string_create(char *str); |
|
|
char *string_dup(char *str); |
|
|
void string_free(char *str); |
|
37 |
char *string_replace(char **str, char *value); |
char *string_replace(char **str, char *value); |
38 |
|
|
|
void mem_get_stat(MEM_STAT *stat); |
|
|
int mem_stat_enumerate(int (*fun)(), void *closure); |
|
|
|
|
39 |
#endif |
#endif |