memory.h 1.39 KB
/***************************************************************************
 * memory.h: Prototypes for default memory operations like memcpy and thus *
 *           on a win32 system nearly all CRT functions (CRT is the        *
 *           windows C RunTime, that is the normal libC) aren't thread-    *
 *           safe. As i build up tests this causes problems for example    *
 *           with strcpy. So i decided to write wrapper that use non CRT   *
 *           functions on Windows and normal libC ones on a posix system.  *
 *                                                                         *
 * Author:   Georg Steffers <georg@steffers.org>                           *
 * Date:     03/06/2006                                                    *
 ***************************************************************************/
#ifndef MEMORY_H
#define MEMORY_H

#include <string.h>
#include <sys/types.h>

#include <scot_common.h>

#define SCOT_MEM_GET          malloc
#define SCOT_MEM_FREE(p)      if ((p)) {free((p)); (p)=NULL;}
#define SCOT_MEM_COPY         memcpy
#define SCOT_MEM_MOVE         memmove
#define SCOT_MEM_FILL         memset
#define SCOT_MEM_ZERO(p,s)    memset ((p), 0, (s))
#define SCOT_STR_LENGTH       strlen
#define SCOT_STR_COPY         strcpy
#define SCOT_STRN_COPY        strncpy
#define SCOT_STR_CHAR         strchr
#define SCOT_STRR_CHAR        strrchr

#endif /* MEMORY_H */