/*********************************************************************\
**                               ________________________________    **
**    A n t h o n y             |________    __    __    ________|   **
**                                       |  |o_|  |o_|  |            **
**            T h y s s e n            __|   __    __   |__          **
**                                  __|   __|  |  |  |__   |__       **
**   `` Dragon Computing ! ''    __|   __|     |  |     |__   |__    **
**                              |_____|        |__|        |_____|   **
**                                                                   **
\*********************************************************************/
/*   A collection of macro routines to handler the allocation
** and deallocation of strings better
*/
#include <Proto/Exec.h>    /* for AllocMem() */
#include <Exec/Memory.h>   /* for memory type flags */
#include <string.h>        /* use builtin strcpy */

#ifdef AMIGA

    /* allocate and copy string -- EG: NewStr=AllocStr(OldStr) */
# define AllocStr(str) \
    strcpy((char *)AllocMem(strlen((str))+1,MEMF_PUBLIC), (str))

    /* Free the prevously allocated string and assign NULL */
# define FreeStr(str) \
    (FreeMem((str), strlen((str))+1), (str)=NULL)

#else /* assume standard C interface */

    /* allocate and copy string -- EG: NewStr=AllocStr(OldStr) */
# define AllocStr(str) \
    strcpy((char *)malloc(strlen((str))+1,MEMF_PUBLIC), (str))

    /* Free the prevously allocated string and assign NULL */
# define FreeStr(str) \
    (free((str)), (str)=NULL)

#endif
