/* Copyright (C) 1994 - 2002 by Telelogic AB.
Copyright (C) 1991, 1992, 1993, 1994 by Telelogic Malmoe AB.
Copyright (C) 1990, 1991, 1999 by Telesoft Europe AB.
This Program is owned by Telelogic and is protected by national
copyright laws and international copyright treaties. Telelogic
grants you the right to use this Program on one computer or in
one local computer network at any one time.
Under this License you may only modify the source code for the purpose
of adapting it to your environment. You must reproduce and include
any copyright and trademark notices on all copies of the source code.
You may not use, copy, merge, modify or transfer the Program except as
provided in this License.
Telelogic does not warrant that the Program will meet your
requirements or that the operation of the Program will be
uninterrupted and error free. You are solely responsible that the
selection of the Program and the modification of the source code
will achieve your intended result and that the results are actually
obtained. */

#ifndef __mms_h
#define __mms_h

/* Memory management system configuration */

#if defined(CODER_MMS_USER)

#include "mms_user.h"

#ifdef USER_BMS_ALLOC_FUNC
#define BMS_ALLOC(coder, size, type)     USER_BMS_ALLOC_FUNC(coder, size, type)
#endif
#ifdef USER_BMS_FREE_FUNC
#define BMS_FREE(coder, ptr, size, type) USER_BMS_FREE_FUNC(coder, ptr, size, type)
#endif

#define CUCF_ALLOC(size, type)           USER_ALLOC_FUNC(size, type)
#define CUCF_FREE(ptr, size, type)       USER_FREE_FUNC(ptr, size, type)

#elif defined(CODER_MMS_SDT)

#include "scttypes.h"

#define CUCF_ALLOC(size, type)           XALLOC(size, type)
#define CUCF_FREE(ptr, size, type)       XFREE((void**)&(ptr), size)

#else /* CODER_MMS_DEFAULT */

#define CUCF_ALLOC(size, type)           malloc(size)
#define CUCF_FREE(ptr, size, type)       free(ptr)
#endif

#ifndef BMS_ALLOC
#define BMS_ALLOC(coder, size, type)     CUCF_ALLOC(size, type)
#endif
#ifndef BMS_FREE
#define BMS_FREE(coder, ptr, size, type) CUCF_FREE(ptr, size, type)
#endif

/* Memory handling */

void MMSRelease(tCoder* Coder);

void  MMSFree(tCoder* Coder, void* Ptr, size_t Size);
void* MMSAlloc(tCoder* Coder, size_t Size);

#define CUCFFree(coder, ptr, size, type) MMSFree(coder, ptr, size)
#define CUCFAlloc(coder, size, type)     MMSAlloc(coder, size)

#endif /* __mms_h */
