📄 inet_msg_mem.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* inet_msg_mem.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file contains memory functions in inet message library.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef _INET_MSG_MEM_C
#define _INET_MSG_MEM_C
#ifdef INET_MSG_LIB_SUPPORT
#include "kal_release.h"
#include "inet_msg_cfg.h"
#include "inet_msg_def.h"
#include "inet_msg_struct.h"
#include "inet_msg_res.h"
#include "inet_msg_mem.h"
#include "inet_msg_util.h"
#include "inet_msg_sip.h"
#ifdef WIN32
#define mIndex 10000
kal_uint32 mem_blocks_table[mIndex][2];
/*****************************************************************************
* FUNCTION
* mem_table_clear
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mem_table_clear()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(mem_blocks_table, 0, mIndex * 8);
}
/*****************************************************************************
* FUNCTION
* add_mem
* DESCRIPTION
*
* PARAMETERS
* ptr [IN]
* size [IN]
* RETURNS
* void
*****************************************************************************/
void add_mem(kal_uint32 ptr, kal_int32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int i, j;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (ptr == 4915296)
{
j = 0;
}
for (i = 0; i < mIndex; i++)
{
if (mem_blocks_table[i][0] == 0)
{
mem_blocks_table[i][0] = ptr;
mem_blocks_table[i][1] = size;
break;
}
}
if (i == (mIndex - 1))
{
printf("alloc shit!!!!!!!!!!!!!!!\n");
}
}
/*****************************************************************************
* FUNCTION
* rm_mem
* DESCRIPTION
*
* PARAMETERS
* ptr [IN]
* RETURNS
* void
*****************************************************************************/
void rm_mem(kal_uint32 ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < mIndex; i++)
{
if (mem_blocks_table[i][0] == ptr)
{
mem_blocks_table[i][0] = 0;
mem_blocks_table[i][1] = 0;
break;
}
}
if (i == (mIndex - 1))
{
printf("free shit!!!!!!!!!!!!!!!\n");
}
}
/*****************************************************************************
* FUNCTION
* print_mem
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void print_mem()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < mIndex; i++)
{
if (mem_blocks_table[i][0] != 0)
{
printf("ptr: %d, size:%d\n", mem_blocks_table[i][0], mem_blocks_table[i][1]);
}
}
}
#endif /* WIN32 */
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* 0 */
/*****************************************************************************
* FUNCTION
* inet_kal_uint32_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_kal_uint32_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 *val, *in_data = (kal_uint32*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!mem_func)
{
return NULL;
}
val = inet_malloc(mem_func, sizeof(kal_uint32));
CHECK_INET_PARAM(val, NULL) * val = *in_data;
return (void*)val;
}
/*****************************************************************************
* FUNCTION
* inet_kal_string_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_kal_string_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_char *val, *in_data = (kal_char*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = (kal_char*) inet_msg_strdup(mem_func, in_data);
CHECK_INET_PARAM(val, NULL) return (void*)val;
}
/*****************************************************************************
* FUNCTION
* inet_param_struct_copy_fn
* DESCRIPTION
*
* PARAMETERS
* mem_func [?]
* src [?]
* RETURNS
* void
*****************************************************************************/
void *inet_param_struct_copy_fn(inet_mem_func_struct *mem_func, void *src)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
inet_param_struct *val, *in_data = (inet_param_struct*) src;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!in_data || !mem_func)
{
return in_data;
}
val = inet_malloc(mem_func, sizeof(inet_param_struct));
CHECK_INET_PARAM(val, NULL) if (in_data->name)
{
val->name = (kal_char*) inet_msg_strdup(mem_func, in_data->name);
}
if (in_data->value)
{
val->value = (kal_char*) inet_msg_strdup(mem_func, in_data->value);
if (!val->value)
{
goto exit_due_to_mem;
}
}
return (void*)val;
exit_due_to_mem:
inet_param_struct_free_fn(mem_func, val);
return NULL;
}
/*****************************************************************************
* FUNCTION
* inet_param_list_struct_copy_fn
* DESCRIPTION
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -