home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
530b.lha
/
AMenu_v1.3
/
AllocStr.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-03
|
2KB
|
39 lines
/*********************************************************************\
** ________________________________ **
** 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