Back to index

php5  5.3.10
gdhelpers.h
Go to the documentation of this file.
00001 #ifndef GDHELPERS_H
00002 #define GDHELPERS_H 1
00003 
00004 #include <sys/types.h>
00005 #include "php.h"
00006 
00007 /* TBB: strtok_r is not universal; provide an implementation of it. */
00008 
00009 extern char *gd_strtok_r(char *s, char *sep, char **state);
00010 
00011 /* These functions wrap memory management. gdFree is
00012        in gd.h, where callers can utilize it to correctly
00013        free memory allocated by these functions with the
00014        right version of free(). */
00015 #define gdCalloc(nmemb, size)      ecalloc(nmemb, size)
00016 #define gdMalloc(size)             emalloc(size)
00017 #define gdRealloc(ptr, size)       erealloc(ptr, size)
00018 #define gdEstrdup(ptr)             estrdup(ptr)
00019 #define gdFree(ptr)         efree(ptr)
00020 #define gdPMalloc(ptr)             pemalloc(ptr, 1)
00021 #define gdPFree(ptr)        pefree(ptr, 1)
00022 #define gdPEstrdup(ptr)            pestrdup(ptr, 1)
00023 
00024 /* Returns nonzero if multiplying the two quantities will
00025        result in integer overflow. Also returns nonzero if 
00026        either quantity is negative. By Phil Knirsch based on
00027        netpbm fixes by Alan Cox. */
00028 
00029 int overflow2(int a, int b);
00030 
00031 #ifdef ZTS
00032 #define gdMutexDeclare(x) MUTEX_T x
00033 #define gdMutexSetup(x) x = tsrm_mutex_alloc()
00034 #define gdMutexShutdown(x) tsrm_mutex_free(x)
00035 #define gdMutexLock(x) tsrm_mutex_lock(x)
00036 #define gdMutexUnlock(x) tsrm_mutex_unlock(x)
00037 #else
00038 #define gdMutexDeclare(x)
00039 #define gdMutexSetup(x)
00040 #define gdMutexShutdown(x)
00041 #define gdMutexLock(x)
00042 #define gdMutexUnlock(x)
00043 #endif
00044 
00045 #endif /* GDHELPERS_H */
00046