q_malloc.c File Reference

#include <stdlib.h>
#include <string.h>
#include "q_malloc.h"
#include "../dprint.h"
#include "../globals.h"
#include "../statistics.h"

Include dependency graph for q_malloc.c:

Go to the source code of this file.

Defines

#define FRAG_CLEAR_USED(f)
#define FRAG_END(f)
#define FRAG_MARK_USED(f)
#define FRAG_NEXT(f)
#define FRAG_OVERHEAD   (sizeof(struct qm_frag)+sizeof(struct qm_frag_end))
#define FRAG_PREV(f)
#define FRAG_WAS_USED(f)   (1)
#define GET_HASH(s)
#define MEM_FRAG_AVOIDANCE
#define PREV_FRAG_END(f)   ((struct qm_frag_end*)((char*)(f)-sizeof(struct qm_frag_end)))
#define q_malloc
#define ROUNDDOWN(s)   ((s)&ROUNDTO_MASK)
#define ROUNDTO_MASK   (~((unsigned long)ROUNDTO-1))
#define ROUNDUP(s)   (((s)+(ROUNDTO-1))&ROUNDTO_MASK)
#define UN_HASH(h)

Functions

static unsigned long big_hash_idx (unsigned long s)
static void qm_detach_free (struct qm_block *qm, struct qm_frag *frag)
static struct qm_fragqm_find_free (struct qm_block *qm, unsigned long size, int *h)
void qm_free (struct qm_block *qm, void *p)
void qm_info (struct qm_block *qm, struct mem_info *info)
static void qm_insert_free (struct qm_block *qm, struct qm_frag *frag)
void * qm_malloc (struct qm_block *qm, unsigned long size)
struct qm_blockqm_malloc_init (char *address, unsigned long size)
void * qm_realloc (struct qm_block *qm, void *p, unsigned long size)
void qm_status (struct qm_block *qm)
static int split_frag (struct qm_block *qm, struct qm_frag *f, unsigned long new_size)


Define Documentation

#define FRAG_CLEAR_USED (  ) 

Definition at line 97 of file q_malloc.c.

Referenced by split_frag().

#define FRAG_END (  ) 

Value:

((struct qm_frag_end*)((char*)(f)+sizeof(struct qm_frag)+ \
      (f)->size))

Definition at line 51 of file q_malloc.c.

Referenced by qm_detach_free(), qm_free(), qm_insert_free(), qm_realloc(), qm_status(), and split_frag().

#define FRAG_MARK_USED (  ) 

Definition at line 96 of file q_malloc.c.

#define FRAG_NEXT (  ) 

Value:

((struct qm_frag*)((char*)(f)+sizeof(struct qm_frag)+(f)->size+ \
      sizeof(struct qm_frag_end)))

Definition at line 55 of file q_malloc.c.

Referenced by qm_free(), qm_realloc(), and qm_status().

#define FRAG_OVERHEAD   (sizeof(struct qm_frag)+sizeof(struct qm_frag_end))

Definition at line 68 of file q_malloc.c.

Referenced by qm_free(), qm_malloc_init(), qm_realloc(), and split_frag().

#define FRAG_PREV (  ) 

Value:

( (struct qm_frag*) ( ((char*)(f)-sizeof(struct qm_frag_end))- \
   ((struct qm_frag_end*)((char*)(f)-sizeof(struct qm_frag_end)))->size- \
      sizeof(struct qm_frag) ) )

Definition at line 59 of file q_malloc.c.

Referenced by qm_free().

#define FRAG_WAS_USED (  )     (1)

Definition at line 98 of file q_malloc.c.

Referenced by qm_status().

#define GET_HASH ( s   ) 

Value:

( ((unsigned long)(s)<=QM_MALLOC_OPTIMIZE)?\
                     (unsigned long)(s)/ROUNDTO: \
                     QM_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
                        QM_MALLOC_OPTIMIZE_FACTOR+1 )

Definition at line 83 of file q_malloc.c.

Referenced by qm_find_free(), qm_free(), qm_insert_free(), and qm_realloc().

#define MEM_FRAG_AVOIDANCE

Definition at line 105 of file q_malloc.c.

#define PREV_FRAG_END (  )     ((struct qm_frag_end*)((char*)(f)-sizeof(struct qm_frag_end)))

Definition at line 64 of file q_malloc.c.

#define q_malloc

Definition at line 39 of file q_malloc.c.

#define ROUNDDOWN ( s   )     ((s)&ROUNDTO_MASK)

Definition at line 73 of file q_malloc.c.

Referenced by qm_malloc_init().

#define ROUNDTO_MASK   (~((unsigned long)ROUNDTO-1))

Definition at line 71 of file q_malloc.c.

#define ROUNDUP ( s   )     (((s)+(ROUNDTO-1))&ROUNDTO_MASK)

Definition at line 72 of file q_malloc.c.

Referenced by qm_malloc(), qm_malloc_init(), and qm_realloc().

#define UN_HASH (  ) 

Value:

( ((unsigned long)(h)<=(QM_MALLOC_OPTIMIZE/ROUNDTO))?\
                     (unsigned long)(h)*ROUNDTO: \
                     1UL<<((h)-QM_MALLOC_OPTIMIZE/ROUNDTO+\
                        QM_MALLOC_OPTIMIZE_FACTOR-1)\
               )

Definition at line 88 of file q_malloc.c.

Referenced by qm_status().


Function Documentation

static unsigned long big_hash_idx ( unsigned long  s  )  [inline, static]

Definition at line 110 of file q_malloc.c.

static void qm_detach_free ( struct qm_block qm,
struct qm_frag frag 
) [inline, static]

Definition at line 255 of file q_malloc.c.

References FRAG_END, qm_frag::nxt_free, and qm_frag::u.

Referenced by qm_free(), qm_malloc(), and qm_realloc().

static struct qm_frag* qm_find_free ( struct qm_block qm,
unsigned long  size,
int *  h 
) [static, read]

void qm_free ( struct qm_block qm,
void *  p 
)

void qm_info ( struct qm_block qm,
struct mem_info info 
)

static void qm_insert_free ( struct qm_block qm,
struct qm_frag frag 
) [inline, static]

void* qm_malloc ( struct qm_block qm,
unsigned long  size 
)

struct qm_block* qm_malloc_init ( char *  address,
unsigned long  size 
) [read]

void* qm_realloc ( struct qm_block qm,
void *  p,
unsigned long  size 
)

void qm_status ( struct qm_block qm  ) 

static int split_frag ( struct qm_block qm,
struct qm_frag f,
unsigned long  new_size 
) [inline, static]


Generated on Thu May 24 08:01:16 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6