/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
#ifndef _LIB_MEM_H
#define _LIB_MEM_H



/*************************************************************************
 *  Definitions 
 *************************************************************************/

#include <stdlib.h>
#include <smldef.h>
#ifdef __ANSI_C__
#include <string.h>
#endif
#ifdef __PALM_OS__
#include <MemoryMgr.h>
#endif


/*************************************************************************
 *  External Functions for all Toolkit versions
 *************************************************************************/


#ifdef __PALM_OS__  /* we use #define to reduce heap usage */
 void *smlLibRealloc (VoidPtr_t objectP, MemSize_t constSize);
 void smlLibFree (void* objectP);
 #define	smlLibMemset(pObject,value,count)		((void)MemSet((VoidPtr_t)pObject,(MemSize_t)count,(int)value))
 #define	smlLibMemcpy(pTarget,pSource,count)		(MemMove(pTarget,(VoidPtr_t)pSource,count) ? pTarget : pTarget)
 #define	smlLibMemmove(pTarget,pSource,count)		(MemMove(pTarget,(VoidPtr_t)pSource,(MemSize_t)count) ? pTarget : pTarget)
 #define	smlLibMemcmp(pTarget,pSource,count)		(MemCmp((VoidPtr_t)pTarget,(VoidPtr_t)pSource,(MemSize_t)count))
 #define	smlLibMalloc(size)		((VoidPtr_t)MemPtrNew((MemSize_t)size))
 #define	smlLibMemsize(pObject)		((MemSize_t)MemPtrSize((VoidPtr_t)pObject))
#else 
  SML_API_DEF void	*smlLibRealloc(void *pObject, MemSize_t size);
  SML_API_DEF void	smlLibFree(void *pObject);
  SML_API_DEF void 	*smlLibMemset(void *pObject, int value, MemSize_t count);
  SML_API_DEF void 	*smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count);
  SML_API_DEF void 	*smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count);
  SML_API_DEF int		smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count);
  SML_API_DEF void	*smlLibMalloc(MemSize_t size);
#endif


#endif

