Skip to content

File memory_alloc.h

FileList > base > memory_alloc.h

Go to the source code of this file

  • #include "config.h"
  • #include "dbtype_def.h"
  • #include "thread_compat.hpp"
  • #include <stdio.h>
  • #include <stdlib.h>
  • #include <limits.h>
  • #include <sys/types.h>
  • #include <stddef.h>
  • #include <string.h>
  • #include <stdint.h>
  • #include <memory>
  • #include <functional>
  • #include "memory_cwrapper.h"

Classes

Type Name
struct private_malloc_header_s

Public Types

Type Name
typedef struct private_malloc_header_s PRIVATE_MALLOC_HEADER
enum memory__alloc_8h_1abed82baf7f470b522273a3e37c24c600

Public Functions

Type Name
int ansisql_strcasecmp (const char * s, const char * t)
int ansisql_strcmp (const char * s, const char * t)
int db_align_to (int n, int alignment)
int db_alignment (int n)
HL_HEAPID db_change_private_heap (THREAD_ENTRY * thread_p, HL_HEAPID heap_id)
void db_clear_private_heap (THREAD_ENTRY * thread_p, HL_HEAPID heap_id)
HL_HEAPID db_create_fixed_heap (int req_size, int recs_per_chunk)
HL_HEAPID db_create_ostk_heap (int chunk_size)
HL_HEAPID db_create_private_heap (void)
void db_destroy_fixed_heap (HL_HEAPID heap_id)
void db_destroy_ostk_heap (HL_HEAPID heap_id)
void db_destroy_private_heap (THREAD_ENTRY * thread_p, HL_HEAPID heap_id)
void * db_fixed_alloc (HL_HEAPID heap_id, size_t size)
void db_fixed_free (HL_HEAPID heap_id, void * ptr)
void * db_ostk_alloc (HL_HEAPID heap_id, size_t size)
void db_ostk_free (HL_HEAPID heap_id, void * ptr)
void * db_private_alloc_debug (THREAD_ENTRY * thrd, size_t size, bool rc_track, const char * caller_file, int caller_line)
void * db_private_alloc_external (THREAD_ENTRY * thrd, size_t size)
void db_private_free_debug (THREAD_ENTRY * thrd, void * ptr, bool rc_track, const char * caller_file, int caller_line)
void db_private_free_external (THREAD_ENTRY * thrd, void * ptr)
void * db_private_realloc_debug (THREAD_ENTRY * thrd, void * ptr, size_t size, bool rc_track, const char * caller_file, int caller_line)
void * db_private_realloc_external (THREAD_ENTRY * thrd, void * ptr, size_t size)
HL_HEAPID db_private_set_heapid_to_thread (THREAD_ENTRY * thread_p, HL_HEAPID heap_id)
char * db_private_strdup (THREAD_ENTRY * thrd, const char * s)
char * db_private_strndup (THREAD_ENTRY * thrd, const char * s, size_t size)
HL_HEAPID db_replace_private_heap (THREAD_ENTRY * thread_p)
void db_scramble (void * region, int size)
void * os_calloc_debug (size_t n, size_t size, bool rc_track, const char * caller_file, int caller_line)
void os_free_debug (void * ptr, bool rc_track, const char * caller_file, int caller_line)
void * os_malloc_debug (size_t size, bool rc_track, const char * caller_file, int caller_line)

Macros

Type Name
define CEIL_PTVDIV (dividend, divisor) ((([**dividend**](broker__monitor_8c.md#function-timeout)) == 0) ? 0 : ((([**dividend**](broker__monitor_8c.md#function-timeout)) - 1) / ([**divisor**](broker__monitor_8c.md#function-timeout))) + 1)
define CHAR_ALIGNMENT [**sizeof**](broker__monitor_8c.md#function-timeout)([**char**](broker__monitor_8c.md#function-timeout))
define DB_ALIGN (offset, align) (((offset) + (align) - 1) & ~((align) - 1))
define DB_ALIGN_BELOW (offset, align) ((offset) & ~((align) - 1))
define DB_ATT_ALIGN (offset) (((offset) + ([**INT\_ALIGNMENT**](memory__alloc_8h.md#define-int_alignment)) - 1) & ~(([**INT\_ALIGNMENT**](memory__alloc_8h.md#define-int_alignment)) - 1))
define DB_SIZEOF (val) ([**sizeof**](broker__monitor_8c.md#function-timeout)(val))
define DB_WASTED_ALIGN (offset, align) ([**DB\_ALIGN**](memory__alloc_8h.md#define-db_align)((offset), (align)) - (offset))
define DOUBLE_ALIGNMENT [**sizeof**](broker__monitor_8c.md#function-timeout)([**double**](broker__monitor_8c.md#function-timeout))
define FLOAT_ALIGNMENT [**sizeof**](broker__monitor_8c.md#function-timeout)([**float**](broker__monitor_8c.md#function-timeout))
define INT_ALIGNMENT [**sizeof**](broker__monitor_8c.md#function-timeout)([**int**](broker__monitor_8c.md#function-timeout))
define LONG_ALIGNMENT [**sizeof**](broker__monitor_8c.md#function-timeout)([**long**](broker__monitor_8c.md#function-timeout))
define MAX_ALIGNMENT [**DOUBLE\_ALIGNMENT**](memory__alloc_8h.md#define-double_alignment)
define MEM_REGION_GUARD_MARK '\02' /\* [**Set**](broker__monitor_8c.md#function-timeout) [**this**](broker__monitor_8c.md#function-timeout) [**as**](broker__monitor_8c.md#function-timeout) [**a**](broker__monitor_8c.md#function-timeout) memory [**guard**](broker__monitor_8c.md#function-timeout) to [**detect**](broker__monitor_8c.md#function-timeout) [**over**](broker__monitor_8c.md#function-timeout)/[**under**](broker__monitor_8c.md#function-timeout) [**runs**](broker__monitor_8c.md#function-timeout) \*/
define MEM_REGION_INIT (region, size) [**memset**](broker__monitor_8c.md#function-timeout)(([**region**](broker__monitor_8c.md#function-timeout)), [**MEM\_REGION\_SCRAMBLE\_MARK**](memory__alloc_8h.md#define-mem_region_scramble_mark), (size))
define MEM_REGION_INIT_MARK '\0' /\* [**Set**](broker__monitor_8c.md#function-timeout) [**this**](broker__monitor_8c.md#function-timeout) to [**allocated**](broker__monitor_8c.md#function-timeout) areas \*/
define MEM_REGION_SCRAMBLE (region, size) [**memset**](broker__monitor_8c.md#function-timeout) ([**region**](broker__monitor_8c.md#function-timeout), [**MEM\_REGION\_SCRAMBLE\_MARK**](memory__alloc_8h.md#define-mem_region_scramble_mark), size)
define MEM_REGION_SCRAMBLE_MARK '\01' /\* [**Set**](broker__monitor_8c.md#function-timeout) [**this**](broker__monitor_8c.md#function-timeout) to [**allocated**](broker__monitor_8c.md#function-timeout) areas \*/
define PRIVATE_MALLOC_HEADER_ALIGNED_SIZE (([**sizeof**](broker__monitor_8c.md#function-timeout)([**PRIVATE\_MALLOC\_HEADER**](memory__alloc_8h.md#typedef-private_malloc_header)) + 7) & ~7)
define PRIVATE_MALLOC_HEADER_MAGIC 0xafdaafdaU
define PTR_ALIGN (addr, boundary) /* multi line expression */
define PTR_ALIGNMENT 8
define SHORT_ALIGNMENT [**sizeof**](broker__monitor_8c.md#function-timeout)([**short**](broker__monitor_8c.md#function-timeout))
define db_private_alloc (thrd, size) [**db\_private\_alloc\_debug**](memory__alloc_8c.md#function-db_private_alloc_debug)(thrd, size, [**true**](broker__monitor_8c.md#function-timeout), [**\_\_FILE\_\_**](broker__monitor_8c.md#function-timeout), [**\_\_LINE\_\_**](broker__monitor_8c.md#function-timeout))
define db_private_free (thrd, ptr) [**db\_private\_free\_debug**](memory__alloc_8c.md#function-db_private_free_debug)(thrd, ptr, [**true**](broker__monitor_8c.md#function-timeout), [**\_\_FILE\_\_**](broker__monitor_8c.md#function-timeout), [**\_\_LINE\_\_**](broker__monitor_8c.md#function-timeout))
define db_private_free_and_init (thrd, ptr) /* multi line expression */
define db_private_realloc (thrd, ptr, size) [**db\_private\_realloc\_debug**](memory__alloc_8c.md#function-db_private_realloc_debug)(thrd, ptr, size, [**true**](broker__monitor_8c.md#function-timeout), [**\_\_FILE\_\_**](broker__monitor_8c.md#function-timeout), [**\_\_LINE\_\_**](broker__monitor_8c.md#function-timeout))
define free_and_init (ptr) /* multi line expression */
define os_calloc (n, size) [**os\_calloc\_debug**](memory__alloc_8c.md#function-os_calloc_debug)(n, size, [**true**](broker__monitor_8c.md#function-timeout), [**\_\_FILE\_\_**](broker__monitor_8c.md#function-timeout), [**\_\_LINE\_\_**](broker__monitor_8c.md#function-timeout))
define os_free (ptr) [**os\_free\_debug**](memory__alloc_8c.md#function-os_free_debug)(ptr, [**true**](broker__monitor_8c.md#function-timeout), [**\_\_FILE\_\_**](broker__monitor_8c.md#function-timeout), [**\_\_LINE\_\_**](broker__monitor_8c.md#function-timeout))
define os_free_and_init (ptr) /* multi line expression */
define os_malloc (size) [**os\_malloc\_debug**](memory__alloc_8c.md#function-os_malloc_debug)(size, [**true**](broker__monitor_8c.md#function-timeout), [**\_\_FILE\_\_**](broker__monitor_8c.md#function-timeout), [**\_\_LINE\_\_**](broker__monitor_8c.md#function-timeout))
define os_realloc (ptr, size) ([**realloc**](memory__cwrapper_8h.md#define-realloc) ((ptr), (size)))
define private_hl2user_ptr (ptr) ([**void**](broker__monitor_8c.md#function-timeout) \*)(([**char**](broker__monitor_8c.md#function-timeout) \*)(ptr) + [**PRIVATE\_MALLOC\_HEADER\_ALIGNED\_SIZE**](memory__alloc_8h.md#define-private_malloc_header_aligned_size))
define private_request_size (s) ([**PRIVATE\_MALLOC\_HEADER\_ALIGNED\_SIZE**](memory__alloc_8h.md#define-private_malloc_header_aligned_size) + (s))
define private_user2hl_ptr (ptr) ([**PRIVATE\_MALLOC\_HEADER**](memory__alloc_8h.md#typedef-private_malloc_header) \*)(([**char**](broker__monitor_8c.md#function-timeout) \*)(ptr) - [**PRIVATE\_MALLOC\_HEADER\_ALIGNED\_SIZE**](memory__alloc_8h.md#define-private_malloc_header_aligned_size))

Public Types Documentation

typedef PRIVATE_MALLOC_HEADER

typedef struct private_malloc_header_s PRIVATE_MALLOC_HEADER;

enum memory__alloc_8h_1abed82baf7f470b522273a3e37c24c600

enum memory__alloc_8h_1abed82baf7f470b522273a3e37c24c600 {
    PRIVATE_ALLOC_TYPE_LEA = 1,
    PRIVATE_ALLOC_TYPE_WS = 2
};

Public Functions Documentation

function ansisql_strcasecmp

int ansisql_strcasecmp (
    const  char * s,
    const  char * t
) 

function ansisql_strcmp

int ansisql_strcmp (
    const  char * s,
    const  char * t
) 

function db_align_to

int db_align_to (
    int n,
    int alignment
) 

function db_alignment

int db_alignment (
    int n
) 

function db_change_private_heap

HL_HEAPID db_change_private_heap (
    THREAD_ENTRY * thread_p,
    HL_HEAPID heap_id
) 

function db_clear_private_heap

void db_clear_private_heap (
    THREAD_ENTRY * thread_p,
    HL_HEAPID heap_id
) 

function db_create_fixed_heap

HL_HEAPID db_create_fixed_heap (
    int req_size,
    int recs_per_chunk
) 

function db_create_ostk_heap

HL_HEAPID db_create_ostk_heap (
    int chunk_size
) 

function db_create_private_heap

HL_HEAPID db_create_private_heap (
    void
) 

function db_destroy_fixed_heap

void db_destroy_fixed_heap (
    HL_HEAPID heap_id
) 

function db_destroy_ostk_heap

void db_destroy_ostk_heap (
    HL_HEAPID heap_id
) 

function db_destroy_private_heap

void db_destroy_private_heap (
    THREAD_ENTRY * thread_p,
    HL_HEAPID heap_id
) 

function db_fixed_alloc

void * db_fixed_alloc (
    HL_HEAPID heap_id,
    size_t size
) 

function db_fixed_free

void db_fixed_free (
    HL_HEAPID heap_id,
    void * ptr
) 

function db_ostk_alloc

void * db_ostk_alloc (
    HL_HEAPID heap_id,
    size_t size
) 

function db_ostk_free

void db_ostk_free (
    HL_HEAPID heap_id,
    void * ptr
) 

function db_private_alloc_debug

void * db_private_alloc_debug (
    THREAD_ENTRY * thrd,
    size_t size,
    bool rc_track,
    const  char * caller_file,
    int caller_line
) 

function db_private_alloc_external

void * db_private_alloc_external (
    THREAD_ENTRY * thrd,
    size_t size
) 

function db_private_free_debug

void db_private_free_debug (
    THREAD_ENTRY * thrd,
    void * ptr,
    bool rc_track,
    const  char * caller_file,
    int caller_line
) 

function db_private_free_external

void db_private_free_external (
    THREAD_ENTRY * thrd,
    void * ptr
) 

function db_private_realloc_debug

void * db_private_realloc_debug (
    THREAD_ENTRY * thrd,
    void * ptr,
    size_t size,
    bool rc_track,
    const  char * caller_file,
    int caller_line
) 

function db_private_realloc_external

void * db_private_realloc_external (
    THREAD_ENTRY * thrd,
    void * ptr,
    size_t size
) 

function db_private_set_heapid_to_thread

HL_HEAPID db_private_set_heapid_to_thread (
    THREAD_ENTRY * thread_p,
    HL_HEAPID heap_id
) 

function db_private_strdup

char * db_private_strdup (
    THREAD_ENTRY * thrd,
    const  char * s
) 

function db_private_strndup

char * db_private_strndup (
    THREAD_ENTRY * thrd,
    const  char * s,
    size_t size
) 

function db_replace_private_heap

HL_HEAPID db_replace_private_heap (
    THREAD_ENTRY * thread_p
) 

function db_scramble

void db_scramble (
    void * region,
    int size
) 

function os_calloc_debug

void * os_calloc_debug (
    size_t n,
    size_t size,
    bool rc_track,
    const  char * caller_file,
    int caller_line
) 

function os_free_debug

void os_free_debug (
    void * ptr,
    bool rc_track,
    const  char * caller_file,
    int caller_line
) 

function os_malloc_debug

void * os_malloc_debug (
    size_t size,
    bool rc_track,
    const  char * caller_file,
    int caller_line
) 

Macro Definition Documentation

define CEIL_PTVDIV

#define CEIL_PTVDIV (
    dividend,
    divisor
) `((( dividend ) == 0) ? 0 : ((( dividend ) - 1) / ( divisor )) + 1)`

define CHAR_ALIGNMENT

#define CHAR_ALIGNMENT `sizeof ( char )`

define DB_ALIGN

#define DB_ALIGN (
    offset,
    align
) `(((offset) + (align) - 1) & ~((align) - 1))`

define DB_ALIGN_BELOW

#define DB_ALIGN_BELOW (
    offset,
    align
) `((offset) & ~((align) - 1))`

define DB_ATT_ALIGN

#define DB_ATT_ALIGN (
    offset
) `(((offset) + ( INT_ALIGNMENT ) - 1) & ~(( INT_ALIGNMENT ) - 1))`

define DB_SIZEOF

#define DB_SIZEOF (
    val
) `( sizeof (val))`

define DB_WASTED_ALIGN

#define DB_WASTED_ALIGN (
    offset,
    align
) `( DB_ALIGN ((offset), (align)) - (offset))`

define DOUBLE_ALIGNMENT

#define DOUBLE_ALIGNMENT `sizeof ( double )`

define FLOAT_ALIGNMENT

#define FLOAT_ALIGNMENT `sizeof ( float )`

define INT_ALIGNMENT

#define INT_ALIGNMENT `sizeof ( int )`

define LONG_ALIGNMENT

#define LONG_ALIGNMENT `sizeof ( long )`

define MAX_ALIGNMENT

#define MAX_ALIGNMENT `DOUBLE_ALIGNMENT`

define MEM_REGION_GUARD_MARK

#define MEM_REGION_GUARD_MARK `'\02'    /* Set  this  as  a memory guard to detect  over / under  runs */`

define MEM_REGION_INIT

#define MEM_REGION_INIT (
    region,
    size
) `memset (( region ), MEM_REGION_SCRAMBLE_MARK , (size))`

define MEM_REGION_INIT_MARK

#define MEM_REGION_INIT_MARK `'\0'  /* Set  this to allocated areas */`

define MEM_REGION_SCRAMBLE

#define MEM_REGION_SCRAMBLE (
    region,
    size
) `memset ( region , MEM_REGION_SCRAMBLE_MARK , size)`

define MEM_REGION_SCRAMBLE_MARK

#define MEM_REGION_SCRAMBLE_MARK `'\01' /* Set  this to allocated areas */`

define PRIVATE_MALLOC_HEADER_ALIGNED_SIZE

#define PRIVATE_MALLOC_HEADER_ALIGNED_SIZE `(( sizeof ( PRIVATE_MALLOC_HEADER ) + 7) & ~7)`

define PRIVATE_MALLOC_HEADER_MAGIC

#define PRIVATE_MALLOC_HEADER_MAGIC `0xafdaafdaU`

define PTR_ALIGN

#define PTR_ALIGN (
    addr,
    boundary
) `/* multi line expression */`

define PTR_ALIGNMENT

#define PTR_ALIGNMENT `8`

define SHORT_ALIGNMENT

#define SHORT_ALIGNMENT `sizeof ( short )`

define db_private_alloc

#define db_private_alloc (
    thrd,
    size
) `db_private_alloc_debug (thrd, size, true , __FILE__ , __LINE__ )`

define db_private_free

#define db_private_free (
    thrd,
    ptr
) `db_private_free_debug (thrd, ptr, true , __FILE__ , __LINE__ )`

define db_private_free_and_init

#define db_private_free_and_init (
    thrd,
    ptr
) `/* multi line expression */`

define db_private_realloc

#define db_private_realloc (
    thrd,
    ptr,
    size
) `db_private_realloc_debug (thrd, ptr, size, true , __FILE__ , __LINE__ )`

define free_and_init

#define free_and_init (
    ptr
) `/* multi line expression */`

define os_calloc

#define os_calloc (
    n,
    size
) `os_calloc_debug (n, size, true , __FILE__ , __LINE__ )`

define os_free

#define os_free (
    ptr
) `os_free_debug (ptr, true , __FILE__ , __LINE__ )`

define os_free_and_init

#define os_free_and_init (
    ptr
) `/* multi line expression */`

define os_malloc

#define os_malloc (
    size
) `os_malloc_debug (size, true , __FILE__ , __LINE__ )`

define os_realloc

#define os_realloc (
    ptr,
    size
) `( realloc ((ptr), (size)))`

define private_hl2user_ptr

#define private_hl2user_ptr (
    ptr
) `( void *)(( char *)(ptr) + PRIVATE_MALLOC_HEADER_ALIGNED_SIZE )`

define private_request_size

#define private_request_size (
    s
) `( PRIVATE_MALLOC_HEADER_ALIGNED_SIZE + (s))`

define private_user2hl_ptr

#define private_user2hl_ptr (
    ptr
) `( PRIVATE_MALLOC_HEADER *)(( char *)(ptr) - PRIVATE_MALLOC_HEADER_ALIGNED_SIZE )`


The documentation for this class was generated from the following file cubrid/src/base/memory_alloc.h