Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Memory Pooling/Allocation
[Core Library]


Defines

#define switch_core_new_memory_pool(p)   switch_core_perform_new_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
 Create a new sub memory pool from the core's master pool.
#define switch_core_destroy_memory_pool(p)   switch_core_perform_destroy_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
 Returns a subpool back to the main pool.
#define switch_core_permanent_alloc(_memory)   switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__)
 Allocate memory from the main pool with no intention of returning it.
#define switch_core_alloc(_pool, _mem)   switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__)
 Allocate memory directly from a memory pool.
#define switch_core_session_alloc(_session, _memory)   switch_core_perform_session_alloc(_session, _memory, __FILE__, __SWITCH_FUNC__, __LINE__)
 Allocate memory from a session's pool.
#define switch_core_permanent_strdup(_todup)   switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 Copy a string using permanent memory allocation.
#define switch_core_session_strdup(_session, _todup)   switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 Copy a string using memory allocation from a session's pool.
#define switch_core_strdup(_pool, _todup)   switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 Copy a string using memory allocation from a given pool.

Functions

switch_status_t switch_core_perform_destroy_memory_pool (_Inout_ switch_memory_pool_t **pool, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
void switch_core_session_run (_In_ switch_core_session_t *session)
 Start the session's state machine.
unsigned int switch_core_session_running (_In_ switch_core_session_t *session)
 determine if the session's state machine is running
void * switch_core_perform_permanent_alloc (_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
void * switch_core_perform_alloc (_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
_Ret_ void * switch_core_perform_session_alloc (_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file, const char *func, int line)
char * switch_core_perform_permanent_strdup (_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
char * switch_core_perform_session_strdup (_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
char * switch_core_perform_strdup (_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
char * switch_core_session_sprintf (_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt,...)
 printf-style style printing routine. The data is output to a string allocated from the session
char * switch_core_sprintf (_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
 printf-style style printing routine. The data is output to a string allocated from the pool
switch_memory_pool_tswitch_core_session_get_pool (_In_ switch_core_session_t *session)
 Retrieve the memory pool from a session.


Define Documentation

#define switch_core_alloc _pool,
_mem   )     switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Allocate memory directly from a memory pool.

Parameters:
_pool the memory pool to allocate from
_mem the number of bytes to allocate
Returns:
a void pointer to the allocated memory

#define switch_core_destroy_memory_pool  )     switch_core_perform_destroy_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Returns a subpool back to the main pool.

Returns:
SWITCH_STATUS_SUCCESS on success

#define switch_core_new_memory_pool  )     switch_core_perform_new_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Create a new sub memory pool from the core's master pool.

Returns:
SWITCH_STATUS_SUCCESS on success

#define switch_core_permanent_alloc _memory   )     switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Allocate memory from the main pool with no intention of returning it.

Parameters:
_memory the number of bytes to allocate
Returns:
a void pointer to the allocated memory
Note:
this memory never goes out of scope until the core is destroyed

#define switch_core_permanent_strdup _todup   )     switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Copy a string using permanent memory allocation.

Parameters:
_todup the string to duplicate
Returns:
a pointer to the newly duplicated string

#define switch_core_session_alloc _session,
_memory   )     switch_core_perform_session_alloc(_session, _memory, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Allocate memory from a session's pool.

Parameters:
_session the session to request memory from
_memory the amount of memory to allocate
Returns:
a void pointer to the newly allocated memory
Note:
the memory will be in scope as long as the session exists

#define switch_core_session_strdup _session,
_todup   )     switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Copy a string using memory allocation from a session's pool.

Parameters:
_session a session to use for allocation
_todup the string to duplicate
Returns:
a pointer to the newly duplicated string

#define switch_core_strdup _pool,
_todup   )     switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Copy a string using memory allocation from a given pool.

Parameters:
_pool the pool to use for allocation
_todup the string to duplicate
Returns:
a pointer to the newly duplicated string


Function Documentation

void* switch_core_perform_alloc _In_ switch_memory_pool_t pool,
_In_ switch_size_t  memory,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line
 

switch_status_t switch_core_perform_destroy_memory_pool _Inout_ switch_memory_pool_t **  pool,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line
 

void* switch_core_perform_permanent_alloc _In_ switch_size_t  memory,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line
 

char* switch_core_perform_permanent_strdup _In_z_ const char *  todup,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line
 

_Ret_ void* switch_core_perform_session_alloc _In_ switch_core_session_t session,
_In_ switch_size_t  memory,
const char *  file,
const char *  func,
int  line
 

char* switch_core_perform_session_strdup _In_ switch_core_session_t session,
_In_z_ const char *  todup,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line
 

char* switch_core_perform_strdup _In_ switch_memory_pool_t pool,
_In_z_ const char *  todup,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line
 

switch_memory_pool_t* switch_core_session_get_pool _In_ switch_core_session_t session  ) 
 

Retrieve the memory pool from a session.

Parameters:
session the session to retrieve the pool from
Returns:
the session's pool
Note:
to be used sparingly

void switch_core_session_run _In_ switch_core_session_t session  ) 
 

Start the session's state machine.

Parameters:
session the session on which to start the state machine

unsigned int switch_core_session_running _In_ switch_core_session_t session  ) 
 

determine if the session's state machine is running

Parameters:
session the session on which to check

char* switch_core_session_sprintf _In_ switch_core_session_t session,
_In_z_ _Printf_format_string_ const char *  fmt,
  ...
 

printf-style style printing routine. The data is output to a string allocated from the session

Parameters:
session a session to use for allocation
fmt The format of the string
... The arguments to use while printing the data
Returns:
The new string

char* switch_core_sprintf _In_ switch_memory_pool_t pool,
_In_z_ _Printf_format_string_ const char *  fmt,
  ...
 

printf-style style printing routine. The data is output to a string allocated from the pool

Parameters:
pool a pool to use for allocation
fmt The format of the string
... The arguments to use while printing the data
Returns:
The new string


Generated on Fri Oct 10 11:24:32 2008 for FreeSWITCH by  doxygen 1.3.9.1