don't expose node allocation functions outside of switch_log.c

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14556 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Mathieu Rene 2009-08-18 18:32:11 +00:00
parent 1c048237d7
commit 8e0dcb4f21
2 changed files with 43 additions and 44 deletions

View File

@ -143,9 +143,6 @@ SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(_In_z_ const char *str);
SWITCH_DECLARE(uint32_t) switch_log_str2mask(_In_z_ const char *str); SWITCH_DECLARE(uint32_t) switch_log_str2mask(_In_z_ const char *str);
#define switch_log_check_mask(_mask, _level) (_mask & (1 << _level)) #define switch_log_check_mask(_mask, _level) (_mask & (1 << _level))
SWITCH_DECLARE(switch_log_node_t*) switch_log_node_alloc();
SWITCH_DECLARE(void) switch_log_node_free(switch_log_node_t **node);
///\} ///\}
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
#endif #endif

View File

@ -78,6 +78,49 @@ static const char*
#endif #endif
COLORS[] = { SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN, SWITCH_SEQ_FYELLOW }; COLORS[] = { SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN, SWITCH_SEQ_FYELLOW };
static switch_log_node_t* switch_log_node_alloc()
{
switch_log_node_t *node = NULL;
#ifdef SWITCH_LOG_RECYCLE
void *pop = NULL;
if (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
node = (switch_log_node_t *) pop;
} else {
#endif
node = malloc(sizeof(*node));
switch_assert(node);
#ifdef SWITCH_LOG_RECYCLE
}
#endif
return node;
}
static void switch_log_node_free(switch_log_node_t **pnode)
{
switch_log_node_t *node;
if (!pnode) {
return;
}
node = *pnode;
if (node) {
switch_safe_free(node->userdata);
switch_safe_free(node->data);
#ifdef SWITCH_LOG_RECYCLE
if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node);
}
#else
free(node);
#endif
}
*pnode = NULL;
}
SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level) SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level)
{ {
if (level > SWITCH_LOG_DEBUG) { if (level > SWITCH_LOG_DEBUG) {
@ -479,47 +522,6 @@ SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_DECLARE(switch_log_node_t*) switch_log_node_alloc()
{
switch_log_node_t *node = NULL;
#ifdef SWITCH_LOG_RECYCLE
void *pop = NULL;
if (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
node = (switch_log_node_t *) pop;
} else {
#endif
node = malloc(sizeof(*node));
switch_assert(node);
#ifdef SWITCH_LOG_RECYCLE
}
#endif
return node;
}
SWITCH_DECLARE(void) switch_log_node_free(switch_log_node_t **pnode)
{
switch_log_node_t *node;
if (!pnode) {
return;
}
node = *pnode;
if (node) {
switch_safe_free(node->userdata);
switch_safe_free(node->data);
#ifdef SWITCH_LOG_RECYCLE
if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node);
}
#else
free(node);
#endif
}
*pnode = NULL;
}
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables: