60 #define _SC_PAGESIZE 2048L
66 case _SC_PAGESIZE:
return 2048L;
103 element->
next = *stack;
117 *stack = (*stack)->
next;
123 #define TR_MAX_MEM_IDX 1024
125 struct memSegment * segments[TR_MAX_MEM_IDX] = {};
130 segmentFree(
struct memSegment * segment,
int depth)
132 while (NULL != segment) {
181 long psize = sysconf(_SC_PAGESIZE);
182 static int psize_width = 0;
185 psize_width = psize_width ? psize_width :
TR_bitwidth(psize);
195 if (0 != (size % psize)) {
218 if (idx < TR_MAX_MEM_IDX) {
219 seg = deleteElement(&(segments[idx]));
244 size_t _size = nmemb *
size;
262 if (-1 != seg->
idx) {
263 insertElement(&(segments[seg->
idx]), seg);
281 for (i=0; i<TR_MAX_MEM_IDX; i++) {
static struct memSegment * newElement(size_t size, int idx)
size_t TR_getSize(void *)
char * TR_strdup(const char *src)
void * TR_malloc(size_t size)
size_t TR_getUsableSize(void *)
void * TR_calloc(size_t nmemb, size_t size)
void * TR_reference(void *mem)