NCBI C++ ToolKit
Classes | Macros | Functions | Variables
ncbi_heapmgr.c File Reference
#include "ncbi_priv.h"
#include <connect/ncbi_heapmgr.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for ncbi_heapmgr.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  SHEAP_HeapBlock
 
struct  SHEAP_tag
 

Macros

#define NCBI_USE_ERRCODE_X   Connect_HeapMgr
 
#define abs(a)   ((a) < 0 ? (a) : -(a))
 
#define HEAP_PACKED   /* */
 
#define _HEAP_ALIGN_EX(a, b)   ((((unsigned long)(a) + ((b) - 1)) / (b)) * (b))
 
#define _HEAP_ALIGN_2(a, b)
 
#define _HEAP_SIZESHIFT   4
 
#define HEAP_BLOCKS(s)   ((s) >> _HEAP_SIZESHIFT)
 
#define HEAP_EXTENT(b)   ((b) << _HEAP_SIZESHIFT)
 
#define HEAP_ALIGN(a)   _HEAP_ALIGN_2(a, HEAP_EXTENT(1))
 
#define HEAP_MASK   (~(HEAP_EXTENT(1) - 1))
 
#define HEAP_PREV_BIT   8
 
#define HEAP_NEXT_BIT   4
 
#define HEAP_LAST   2
 
#define HEAP_USED   1
 
#define HEAP_SIZE(s)   ((s) & (unsigned long) HEAP_MASK)
 
#define HEAP_FLAG(s)   ((s) & (unsigned long)(~HEAP_MASK))
 
#define HEAP_NEXT(b)
 
#define HEAP_PREV(b)
 
#define HEAP_INDEX(b, base)   ((TNCBI_Size)((b) - (base)))
 
#define HEAP_ISLAST(b)   ((b)->head.flag & HEAP_LAST)
 
#define HEAP_ISUSED(b)   ((b)->head.flag & HEAP_USED)
 
#define HEAP_CHECK(heap)
 
#define s_HEAP_Unlink(b)   { b->prevfree = b->nextfree = ~((TNCBI_Size) 0); }
 

Functions

HEAP HEAP_Create (void *base, TNCBI_Size size, TNCBI_Size chunk, FHEAP_Resize resize, void *auxarg)
 
HEAP HEAP_AttachFast (const void *base, TNCBI_Size size, int serial)
 
HEAP HEAP_Attach (const void *base, TNCBI_Size maxsize, int serial)
 
static const char * s_HEAP_Id (char *buf, HEAP h)
 
static SHEAP_HeapBlocks_HEAP_Find (HEAP heap, TNCBI_Size need, SHEAP_HeapBlock *hint)
 
static void s_HEAP_Link (HEAP heap, SHEAP_HeapBlock *f, SHEAP_HeapBlock *hint)
 
static SHEAP_HeapBlocks_HEAP_Collect (HEAP heap, TNCBI_Size need)
 
static SHEAP_Blocks_HEAP_Take (HEAP heap, SHEAP_HeapBlock *b, SHEAP_HeapBlock *n, TNCBI_Size size, TNCBI_Size need, int tail)
 
SHEAP_BlockHEAP_Alloc (HEAP heap, TNCBI_Size size, int tail)
 
static void s_HEAP_Free (HEAP heap, SHEAP_HeapBlock *p, SHEAP_HeapBlock *b, SHEAP_HeapBlock *n)
 
void HEAP_Free (HEAP heap, SHEAP_Block *ptr)
 
void HEAP_FreeFast (HEAP heap, SHEAP_Block *ptr, const SHEAP_Block *prev)
 
HEAP HEAP_Trim (HEAP heap)
 
static SHEAP_HeapBlockx_HEAP_Walk (const HEAP heap, const SHEAP_Block *ptr)
 
static SHEAP_HeapBlocks_HEAP_Walk (const HEAP heap, const SHEAP_Block *ptr)
 
SHEAP_BlockHEAP_Walk (const HEAP heap, const SHEAP_Block *ptr)
 
SHEAP_BlockHEAP_Next (const HEAP heap, const SHEAP_Block *ptr)
 
HEAP HEAP_Copy (const HEAP heap, size_t extra, int serial)
 
unsigned int HEAP_AddRef (HEAP heap)
 
unsigned int HEAP_Detach (HEAP heap)
 
unsigned int HEAP_Destroy (HEAP heap)
 
void * HEAP_Base (const HEAP heap)
 
TNCBI_Size HEAP_Size (const HEAP heap)
 
TNCBI_Size HEAP_Used (const HEAP heap)
 
TNCBI_Size HEAP_Idle (const HEAP heap)
 
int HEAP_Serial (const HEAP heap)
 
void HEAP_Options (ESwitch fast, ESwitch unused)
 

Variables

static int s_HEAP_fast = 1
 

Macro Definition Documentation

◆ _HEAP_ALIGN_2

#define _HEAP_ALIGN_2 (   a,
  b 
)
Value:
(( (unsigned long)(a) + ((b) - 1)) \
& (unsigned long)(~((b) - 1)/*or -(b)*/))
unsigned int a
Definition: ncbi_localip.c:102

Definition at line 175 of file ncbi_heapmgr.c.

◆ _HEAP_ALIGN_EX

#define _HEAP_ALIGN_EX (   a,
  b 
)    ((((unsigned long)(a) + ((b) - 1)) / (b)) * (b))

Definition at line 174 of file ncbi_heapmgr.c.

◆ _HEAP_SIZESHIFT

#define _HEAP_SIZESHIFT   4

Definition at line 177 of file ncbi_heapmgr.c.

◆ abs

#define abs (   a)    ((a) < 0 ? (a) : -(a))

Definition at line 130 of file ncbi_heapmgr.c.

◆ HEAP_ALIGN

#define HEAP_ALIGN (   a)    _HEAP_ALIGN_2(a, HEAP_EXTENT(1))

Definition at line 180 of file ncbi_heapmgr.c.

◆ HEAP_BLOCKS

#define HEAP_BLOCKS (   s)    ((s) >> _HEAP_SIZESHIFT)

Definition at line 178 of file ncbi_heapmgr.c.

◆ HEAP_CHECK

#define HEAP_CHECK (   heap)
Value:
assert(!heap->base == !heap->size); \
assert(heap->used <= heap->size); \
assert(heap->free <= heap->size); \
assert(heap->last <= heap->size); \
assert(heap->used == heap->size || heap->free < heap->size)
static int heap[2 *(256+1+29)+1]
#define assert(x)
Definition: srv_diag.hpp:58

Definition at line 196 of file ncbi_heapmgr.c.

◆ HEAP_EXTENT

#define HEAP_EXTENT (   b)    ((b) << _HEAP_SIZESHIFT)

Definition at line 179 of file ncbi_heapmgr.c.

◆ HEAP_FLAG

#define HEAP_FLAG (   s)    ((s) & (unsigned long)(~HEAP_MASK))

Definition at line 187 of file ncbi_heapmgr.c.

◆ HEAP_INDEX

#define HEAP_INDEX (   b,
  base 
)    ((TNCBI_Size)((b) - (base)))

Definition at line 192 of file ncbi_heapmgr.c.

◆ HEAP_ISLAST

#define HEAP_ISLAST (   b)    ((b)->head.flag & HEAP_LAST)

Definition at line 193 of file ncbi_heapmgr.c.

◆ HEAP_ISUSED

#define HEAP_ISUSED (   b)    ((b)->head.flag & HEAP_USED)

Definition at line 194 of file ncbi_heapmgr.c.

◆ HEAP_LAST

#define HEAP_LAST   2

Definition at line 184 of file ncbi_heapmgr.c.

◆ HEAP_MASK

#define HEAP_MASK   (~(HEAP_EXTENT(1) - 1))

Definition at line 181 of file ncbi_heapmgr.c.

◆ HEAP_NEXT

#define HEAP_NEXT (   b)
Value:
((char*)(b) + (b)->head.size))

Definition at line 188 of file ncbi_heapmgr.c.

◆ HEAP_NEXT_BIT

#define HEAP_NEXT_BIT   4

Definition at line 183 of file ncbi_heapmgr.c.

◆ HEAP_PACKED

#define HEAP_PACKED   /* */

Definition at line 145 of file ncbi_heapmgr.c.

◆ HEAP_PREV

#define HEAP_PREV (   b)
Value:
((char*)(b) - HEAP_SIZE((b)->head.flag)))
#define HEAP_SIZE(s)
Definition: ncbi_heapmgr.c:186

Definition at line 190 of file ncbi_heapmgr.c.

◆ HEAP_PREV_BIT

#define HEAP_PREV_BIT   8

Definition at line 182 of file ncbi_heapmgr.c.

◆ HEAP_SIZE

#define HEAP_SIZE (   s)    ((s) & (unsigned long) HEAP_MASK)

Definition at line 186 of file ncbi_heapmgr.c.

◆ HEAP_USED

#define HEAP_USED   1

Definition at line 185 of file ncbi_heapmgr.c.

◆ NCBI_USE_ERRCODE_X

#define NCBI_USE_ERRCODE_X   Connect_HeapMgr

Definition at line 120 of file ncbi_heapmgr.c.

◆ s_HEAP_Unlink

#define s_HEAP_Unlink (   b)    { b->prevfree = b->nextfree = ~((TNCBI_Size) 0); }

Definition at line 499 of file ncbi_heapmgr.c.

Function Documentation

◆ s_HEAP_Collect()

static SHEAP_HeapBlock* s_HEAP_Collect ( HEAP  heap,
TNCBI_Size  need 
)
static

◆ s_HEAP_Find()

static SHEAP_HeapBlock* s_HEAP_Find ( HEAP  heap,
TNCBI_Size  need,
SHEAP_HeapBlock hint 
)
static

◆ s_HEAP_Free()

static void s_HEAP_Free ( HEAP  heap,
SHEAP_HeapBlock p,
SHEAP_HeapBlock b,
SHEAP_HeapBlock n 
)
static

◆ s_HEAP_Id()

static const char* s_HEAP_Id ( char *  buf,
HEAP  h 
)
static

◆ s_HEAP_Link()

static void s_HEAP_Link ( HEAP  heap,
SHEAP_HeapBlock f,
SHEAP_HeapBlock hint 
)
static

◆ s_HEAP_Take()

static SHEAP_Block* s_HEAP_Take ( HEAP  heap,
SHEAP_HeapBlock b,
SHEAP_HeapBlock n,
TNCBI_Size  size,
TNCBI_Size  need,
int  tail 
)
static

◆ s_HEAP_Walk()

static SHEAP_HeapBlock* s_HEAP_Walk ( const HEAP  heap,
const SHEAP_Block ptr 
)
static

Definition at line 1203 of file ncbi_heapmgr.c.

References assert, b, head, heap, HEAP_ISLAST, HEAP_NEXT, likely, s_HEAP_fast, unlikely, and x_HEAP_Walk().

Referenced by HEAP_Next(), and HEAP_Walk().

◆ x_HEAP_Walk()

static SHEAP_HeapBlock* x_HEAP_Walk ( const HEAP  heap,
const SHEAP_Block ptr 
)
static

Variable Documentation

◆ s_HEAP_fast

int s_HEAP_fast = 1
static

Definition at line 171 of file ncbi_heapmgr.c.

Referenced by HEAP_FreeFast(), HEAP_Options(), HEAP_Trim(), s_HEAP_Find(), and s_HEAP_Walk().

Modified on Wed Sep 04 15:04:13 2024 by modify_doxy.py rev. 669887