📄 inet_msg_mem.c
字号:
{
goto exit_due_to_mem;
}
}
if (in_data->mime_subtype)
{
val->mime_subtype = (kal_char*) inet_msg_strdup(mem_func, in_data->mime_subtype);
if (!val->mime_subtype)
{
goto exit_due_to_mem;
}
}
if (in_data->param_list)
{
val->param_list = inet_param_list_struct_copy_fn(mem_func, in_data->param_list);
if (!val->param_list)
{
goto exit_due_to_mem;
}
}
return (void*)val;
exit_due_to_mem:
inet_content_type_struct_free_fn(mem_func, val);
return NULL;
}
/*****************************************************************************
* FUNCTION
* inet_content_type_list_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_content_type_list_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
inet_content_type_list_struct *val, *val_t, *in_data = (inet_content_type_list_struct*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = inet_malloc(mem_func, sizeof(inet_content_type_list_struct));
CHECK_INET_PARAM(val, NULL);
val_t = val;
while (in_data)
{
if (in_data->object)
{
val->object = inet_content_type_struct_copy_fn(mem_func, in_data->object);
if (!val->object)
{
goto exit_due_to_mem;
}
}
in_data = in_data->next;
if (in_data)
{
if (val->object)
{
val->next = inet_malloc(mem_func, sizeof(inet_content_type_list_struct));
val = val->next;
if (!val)
{
goto exit_due_to_mem;
}
}
}
}
return (void*)val_t;
exit_due_to_mem:
inet_content_type_list_struct_free_fn(mem_func, val_t);
return NULL;
}
/*****************************************************************************
* FUNCTION
* inet_cseq_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_cseq_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
inet_cseq_struct *val, *in_data = (inet_cseq_struct*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = inet_malloc(mem_func, sizeof(inet_cseq_struct));
CHECK_INET_PARAM(val, NULL);
val->method = in_data->method;
val->seq = in_data->seq;
return (void*)val;
}
/*****************************************************************************
* FUNCTION
* inet_via_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_via_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
inet_via_struct *val, *in_data = (inet_via_struct*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = inet_malloc(mem_func, sizeof(inet_via_struct));
CHECK_INET_PARAM(val, NULL);
val->app_type = in_data->app_type;
val->port = in_data->port;
if (in_data->proto_name)
{
val->proto_name = (kal_char*) inet_msg_strdup(mem_func, in_data->proto_name);
if (!val->proto_name)
{
goto exit_due_to_mem;
}
}
if (in_data->version)
{
val->version = (kal_char*) inet_msg_strdup(mem_func, in_data->version);
if (!val->version)
{
goto exit_due_to_mem;
}
}
if (in_data->transport)
{
val->transport = (kal_char*) inet_msg_strdup(mem_func, in_data->transport);
if (!val->transport)
{
goto exit_due_to_mem;
}
}
if (in_data->host)
{
val->host = (kal_char*) inet_msg_strdup(mem_func, in_data->host);
if (!val->host)
{
goto exit_due_to_mem;
}
}
if (in_data->comment)
{
val->comment = (kal_char*) inet_msg_strdup(mem_func, in_data->comment);
if (!val->comment)
{
goto exit_due_to_mem;
}
}
if (in_data->param_list)
{
val->param_list = inet_param_list_struct_copy_fn(mem_func, in_data->param_list);
if (!val->param_list)
{
goto exit_due_to_mem;
}
}
return (void*)val;
exit_due_to_mem:
inet_authentication_info_struct_free_fn(mem_func, val);
return NULL;
}
/*****************************************************************************
* FUNCTION
* inet_via_list_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_via_list_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
inet_content_type_list_struct *val, *val_t, *in_data = (inet_content_type_list_struct*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = inet_malloc(mem_func, sizeof(inet_content_type_list_struct));
CHECK_INET_PARAM(val, NULL);
val_t = val;
while (in_data)
{
if (in_data->object)
{
val->object = inet_via_struct_copy_fn(mem_func, in_data->object);
if (!val->object)
{
goto exit_due_to_mem;
}
}
in_data = in_data->next;
if (in_data)
{
if (val->object)
{
val->next = inet_malloc(mem_func, sizeof(inet_content_type_list_struct));
val = val->next;
if (!val)
{
goto exit_due_to_mem;
}
}
}
}
return (void*)val_t;
exit_due_to_mem:
inet_content_type_list_struct_free_fn(mem_func, val_t);
return NULL;
}
/*****************************************************************************
* FUNCTION
* inet_retry_after_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_retry_after_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
inet_retry_after_struct *val, *in_data = (inet_retry_after_struct*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = inet_malloc(mem_func, sizeof(inet_retry_after_struct));
CHECK_INET_PARAM(val, NULL);
val->isDateString = in_data->isDateString;
val->time = in_data->time;
return (void*)val;
}
/*****************************************************************************
* FUNCTION
* inet_malloc
* DESCRIPTION
* This function is used to allocate memory.
* PARAMETERS
* mem_func [?]
* size [IN] memory size being allocated
* alloc_fn, memory allocation function(?)
* RETURNS
* void
*****************************************************************************/
void *inet_malloc(inet_mem_func_struct *mem_func, kal_uint32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
void *ptr;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/*
* INET_MSG_ASSERT(mem_func && mem_func->alloc_fn && size != 0);
*/
ptr = (mem_func->alloc_fn) (size);
if (!ptr)
{
return NULL;
}
kal_mem_set(ptr, 0, size);
#ifdef WIN32
add_mem((kal_uint32) ptr, size);
#endif
#ifdef INET_MSG_MEM_DEBUG
/* inet_mem_dbg_alloc(mem->mem_dbg, ptr, size); */
#endif
return ptr;
}
/*****************************************************************************
* FUNCTION
* inet_mfree
* DESCRIPTION
* This function is used to free memory.
* PARAMETERS
* mem_func [?]
* ptr [?] poitner of memory being freed
* free_fn, memory free function.(?)
* RETURNS
* void
*****************************************************************************/
void inet_mfree(inet_mem_func_struct *mem_func, void *ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*
* INET_MSG_ASSERT(mem_func && mem_func->free_fn && ptr);
*/
#ifdef INET_MSG_MEM_DEBUG
/* inet_mem_dbg_free(mem->mem_dbg, ptr); */
#endif
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
(mem_func->free_fn) (ptr);
#ifdef WIN32
rm_mem((kal_uint32) ptr);
#endif
}
/*****************************************************************************
* FUNCTION
* inet_param_struct_free_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* data [?]
* RETURNS
* void
*****************************************************************************/
void inet_param_struct_free_fn(inet_mem_func_struct *mem_func, void *data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (data)
{
inet_param_struct *obj = (inet_param_struct*) data;
if (obj->name)
{
inet_mfree(mem_func, obj->name);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -