1/*************************************************************************/ 2/* module: Library for Memory Functions */ 3/* */ 4/* file: libmem.h */ 5/* target system: ALL */ 6/* target OS: ALL */ 7/* */ 8/* Description: */ 9/* Header for the implementation of common memory handling functions */ 10/*************************************************************************/ 11 12 13 14/* 15 * Copyright Notice 16 * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication 17 * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc., 18 * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). 19 * All Rights Reserved. 20 * Implementation of all or part of any Specification may require 21 * licenses under third party intellectual property rights, 22 * including without limitation, patent rights (such a third party 23 * may or may not be a Supporter). The Sponsors of the Specification 24 * are not responsible and shall not be held responsible in any 25 * manner for identifying or failing to identify any or all such 26 * third party intellectual property rights. 27 * 28 * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED 29 * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM, 30 * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA, 31 * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML 32 * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 33 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 34 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 35 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 36 * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO., 37 * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY 38 * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF 39 * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF 40 * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, 41 * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH 42 * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED 43 * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. 44 * 45 * The above notice and this paragraph must be included on all copies 46 * of this document that are made. 47 * 48 */ 49 50 51 52#ifndef _LIB_MEM_H 53#define _LIB_MEM_H 54 55 56 57/************************************************************************* 58 * Definitions 59 *************************************************************************/ 60 61#include <stdlib.h> 62#include <smldef.h> 63#ifdef __ANSI_C__ 64#include <string.h> 65#endif 66#ifdef __PALM_OS__ 67#include <MemoryMgr.h> 68#endif 69 70#include "dmMemory.h" 71 72/************************************************************************* 73 * External Functions for all Toolkit versions 74 *************************************************************************/ 75 76 77#ifdef __PALM_OS__ /* we use #define to reduce heap usage */ 78 void *smlLibRealloc (VoidPtr_t objectP, MemSize_t constSize); 79 void smlLibFree (void* objectP); 80 #define smlLibMemset(pObject,value,count) ((void)MemSet((VoidPtr_t)pObject,(MemSize_t)count,(int)value)) 81 #define smlLibMemcpy(pTarget,pSource,count) (MemMove(pTarget,(VoidPtr_t)pSource,count) ? pTarget : pTarget) 82 #define smlLibMemmove(pTarget,pSource,count) (MemMove(pTarget,(VoidPtr_t)pSource,(MemSize_t)count) ? pTarget : pTarget) 83 #define smlLibMemcmp(pTarget,pSource,count) (MemCmp((VoidPtr_t)pTarget,(VoidPtr_t)pSource,(MemSize_t)count)) 84 #define smlLibMalloc(size) ((VoidPtr_t)MemPtrNew((MemSize_t)size)) 85 #define smlLibMemsize(pObject) ((MemSize_t)MemPtrSize((VoidPtr_t)pObject)) 86#else 87 SML_API_DEF void *smlLibRealloc(void *pObject, MemSize_t size); 88 SML_API_DEF void smlLibFree(void *pObject); 89 SML_API_DEF void *smlLibMemset(void *pObject, int value, MemSize_t count); 90 SML_API_DEF void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count); 91 SML_API_DEF void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count); 92 SML_API_DEF int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count); 93 //SML_API_DEF void *smlLibMalloc(MemSize_t size); 94 #define smlLibMalloc DmAllocMem 95#endif 96 97 98#endif 99 100