CUBRID Engine  latest
lea_heap.c File Reference
#include <stdlib.h>
#include <stddef.h>
#include "customheaps.h"
#include "error_manager.h"
#include "system_parameter.h"
#include "malloc_2_8_3.c"
Include dependency graph for lea_heap.c:

Go to the source code of this file.

Classes

struct  mmap_trace_h_s
 
struct  hl_mspace_s
 

Macros

#define USE_MALLOC_INSTEAD   1
 
#define MOCK_LEA_HEAP_ID   ((UINTPTR)(-1))
 
#define system_malloc   my_malloc
 
#define system_free   my_free
 
#define DEFAULT_GRANULARITY   (32U*1024U)
 
#define ONLY_MSPACES   1
 
#define MMAP_TRACE_H_SIZE   sizeof(MMAP_TRACE_H)
 
#define MMAP_TRACE_H_INIT(h, p)
 
#define MMAP_TRACE_H_REMOVE(h)
 
#define MMAP_TRACE_H_ADD(p, h)
 
#define ENABLE_SEPARATE_MMAP_EVENT_TRACE
 
#define mspace2hlmspace(m)   (HL_MSPACE *)((char *)mem2chunk(m) - ((sizeof (HL_MSPACE) + 7U) & ~7U))
 
#define LEA_HEAP_BASE_SIZE   (64U*1024U)
 

Typedefs

typedef struct mmap_trace_h_s MMAP_TRACE_H
 
typedef struct hl_mspace_s HL_MSPACE
 

Functions

static void * my_malloc (size_t sz)
 
static int my_free (void *p)
 
static void mmap_called (void *m, void *ptr, MMAP_TRACE_H *h)
 
static void munmap_is_to_be_called (void *m, void *ptr, MMAP_TRACE_H *h)
 
UINTPTR hl_register_lea_heap (void)
 
static void destroy_mspace_internal (HL_MSPACE *hms)
 
void hl_clear_lea_heap (UINTPTR heap_id)
 
void hl_unregister_lea_heap (UINTPTR heap_id)
 
void * hl_lea_alloc (UINTPTR heap_id, size_t sz)
 
void * hl_lea_realloc (UINTPTR heap_id, void *ptr, size_t sz)
 
void hl_lea_free (UINTPTR heap_id, void *ptr)
 

Macro Definition Documentation

#define DEFAULT_GRANULARITY   (32U*1024U)

Definition at line 58 of file lea_heap.c.

#define ENABLE_SEPARATE_MMAP_EVENT_TRACE

Definition at line 113 of file lea_heap.c.

#define LEA_HEAP_BASE_SIZE   (64U*1024U)

Definition at line 206 of file lea_heap.c.

Referenced by hl_register_lea_heap().

#define MMAP_TRACE_H_ADD (   p,
 
)
Value:
do { \
MMAP_TRACE_H *__ih = (p); \
MMAP_TRACE_H *__bh = (h); \
(__ih)->prev = (__bh); \
(__ih)->next = (__bh)->next; \
(__bh)->next->prev = (__ih); \
(__bh)->next = (__ih); \
} while (0)
struct mmap_trace_h_s MMAP_TRACE_H
Definition: lea_heap.c:79
MMAP_TRACE_H * prev
Definition: lea_heap.c:83
MMAP_TRACE_H * next
Definition: lea_heap.c:82
const char ** p
Definition: dynamic_load.c:945

Definition at line 101 of file lea_heap.c.

Referenced by mmap_called().

#define MMAP_TRACE_H_INIT (   h,
  p 
)
Value:
do { \
MMAP_TRACE_H *__h = (h); \
(__h)->next = (__h)->prev = (__h); \
(__h)->ptr = (p); \
} while (0)
struct mmap_trace_h_s MMAP_TRACE_H
Definition: lea_heap.c:79
MMAP_TRACE_H * prev
Definition: lea_heap.c:83
const char ** p
Definition: dynamic_load.c:945

Definition at line 89 of file lea_heap.c.

Referenced by hl_register_lea_heap(), and mmap_called().

#define MMAP_TRACE_H_REMOVE (   h)
Value:
do { \
MMAP_TRACE_H *__h = (h); \
(__h)->next->prev = (__h)->prev; \
(__h)->prev->next = (__h)->next; \
} while (0)
struct mmap_trace_h_s MMAP_TRACE_H
Definition: lea_heap.c:79
MMAP_TRACE_H * prev
Definition: lea_heap.c:83
MMAP_TRACE_H * next
Definition: lea_heap.c:82

Definition at line 95 of file lea_heap.c.

Referenced by destroy_mspace_internal(), and munmap_is_to_be_called().

#define MMAP_TRACE_H_SIZE   sizeof(MMAP_TRACE_H)

Definition at line 87 of file lea_heap.c.

Referenced by dlmallopt(), mmap_alloc(), and mmap_resize().

#define MOCK_LEA_HEAP_ID   ((UINTPTR)(-1))

Definition at line 48 of file lea_heap.c.

Referenced by hl_clear_lea_heap(), hl_register_lea_heap(), and hl_unregister_lea_heap().

#define mspace2hlmspace (   m)    (HL_MSPACE *)((char *)mem2chunk(m) - ((sizeof (HL_MSPACE) + 7U) & ~7U))

Definition at line 170 of file lea_heap.c.

Referenced by mmap_called(), and munmap_is_to_be_called().

#define ONLY_MSPACES   1

Definition at line 72 of file lea_heap.c.

#define system_free   my_free

Definition at line 50 of file lea_heap.c.

#define system_malloc   my_malloc

Definition at line 49 of file lea_heap.c.

#define USE_MALLOC_INSTEAD   1

Definition at line 47 of file lea_heap.c.

Typedef Documentation

typedef struct hl_mspace_s HL_MSPACE

Definition at line 151 of file lea_heap.c.

typedef struct mmap_trace_h_s MMAP_TRACE_H

Definition at line 79 of file lea_heap.c.

Function Documentation

static void destroy_mspace_internal ( HL_MSPACE hms)
static

Definition at line 252 of file lea_heap.c.

References hl_mspace_s::header, MMAP_TRACE_H_REMOVE, hl_mspace_s::ms, my_free(), mmap_trace_h_s::next, NULL, and mmap_trace_h_s::ptr.

Referenced by hl_clear_lea_heap(), and hl_unregister_lea_heap().

Here is the caller graph for this function:

void hl_clear_lea_heap ( UINTPTR  heap_id)

Definition at line 272 of file lea_heap.c.

References assert, hl_mspace_s::base, hl_mspace_s::base_size, destroy_mspace_internal(), MOCK_LEA_HEAP_ID, hl_mspace_s::ms, NULL, prm_get_bool_value(), and PRM_ID_USE_SYSTEM_MALLOC.

Referenced by db_clear_private_heap().

Here is the caller graph for this function:

void* hl_lea_alloc ( UINTPTR  heap_id,
size_t  sz 
)

Definition at line 326 of file lea_heap.c.

References ARG_FILE_LINE, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), hl_mspace_s::ms, NULL, p, prm_get_bool_value(), and PRM_ID_USE_SYSTEM_MALLOC.

Referenced by db_private_alloc_debug(), and db_ws_alloc().

Here is the caller graph for this function:

void hl_lea_free ( UINTPTR  heap_id,
void *  ptr 
)

Definition at line 395 of file lea_heap.c.

References hl_mspace_s::ms, NULL, prm_get_bool_value(), and PRM_ID_USE_SYSTEM_MALLOC.

Referenced by db_private_free_debug(), and db_ws_free().

Here is the caller graph for this function:

void* hl_lea_realloc ( UINTPTR  heap_id,
void *  ptr,
size_t  sz 
)

Definition at line 361 of file lea_heap.c.

References ARG_FILE_LINE, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), hl_mspace_s::ms, NULL, p, prm_get_bool_value(), and PRM_ID_USE_SYSTEM_MALLOC.

Referenced by db_private_realloc_debug(), and db_ws_realloc().

Here is the caller graph for this function:

UINTPTR hl_register_lea_heap ( void  )
void hl_unregister_lea_heap ( UINTPTR  heap_id)

Definition at line 299 of file lea_heap.c.

References assert, destroy_mspace_internal(), MOCK_LEA_HEAP_ID, NULL, prm_get_bool_value(), and PRM_ID_USE_SYSTEM_MALLOC.

Referenced by db_destroy_private_heap(), and db_destroy_workspace_heap().

Here is the caller graph for this function:

static void mmap_called ( void *  m,
void *  ptr,
MMAP_TRACE_H h 
)
static

Definition at line 182 of file lea_heap.c.

References hl_mspace_s::header, MMAP_TRACE_H_ADD, MMAP_TRACE_H_INIT, and mspace2hlmspace.

Referenced by mmap_alloc().

Here is the caller graph for this function:

static void munmap_is_to_be_called ( void *  m,
void *  ptr,
MMAP_TRACE_H h 
)
static

Definition at line 198 of file lea_heap.c.

References assert, MMAP_TRACE_H_REMOVE, mspace2hlmspace, and mmap_trace_h_s::ptr.

Referenced by dlmallopt().

Here is the caller graph for this function:

static int my_free ( void *  p)
static

Definition at line 141 of file lea_heap.c.

Referenced by destroy_mspace_internal().

Here is the caller graph for this function:

static void * my_malloc ( size_t  sz)
static

Definition at line 122 of file lea_heap.c.

References CMFAIL, NULL, and mmap_trace_h_s::ptr.