summaryrefslogtreecommitdiff
path: root/ext/gd/libgd/gdhelpers.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/gd/libgd/gdhelpers.h
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/gd/libgd/gdhelpers.h')
-rw-r--r--ext/gd/libgd/gdhelpers.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/ext/gd/libgd/gdhelpers.h b/ext/gd/libgd/gdhelpers.h
new file mode 100644
index 0000000..6c46972
--- /dev/null
+++ b/ext/gd/libgd/gdhelpers.h
@@ -0,0 +1,46 @@
+#ifndef GDHELPERS_H
+#define GDHELPERS_H 1
+
+#include <sys/types.h>
+#include "php.h"
+
+/* TBB: strtok_r is not universal; provide an implementation of it. */
+
+extern char *gd_strtok_r(char *s, char *sep, char **state);
+
+/* These functions wrap memory management. gdFree is
+ in gd.h, where callers can utilize it to correctly
+ free memory allocated by these functions with the
+ right version of free(). */
+#define gdCalloc(nmemb, size) ecalloc(nmemb, size)
+#define gdMalloc(size) emalloc(size)
+#define gdRealloc(ptr, size) erealloc(ptr, size)
+#define gdEstrdup(ptr) estrdup(ptr)
+#define gdFree(ptr) efree(ptr)
+#define gdPMalloc(ptr) pemalloc(ptr, 1)
+#define gdPFree(ptr) pefree(ptr, 1)
+#define gdPEstrdup(ptr) pestrdup(ptr, 1)
+
+/* Returns nonzero if multiplying the two quantities will
+ result in integer overflow. Also returns nonzero if
+ either quantity is negative. By Phil Knirsch based on
+ netpbm fixes by Alan Cox. */
+
+int overflow2(int a, int b);
+
+#ifdef ZTS
+#define gdMutexDeclare(x) MUTEX_T x
+#define gdMutexSetup(x) x = tsrm_mutex_alloc()
+#define gdMutexShutdown(x) tsrm_mutex_free(x)
+#define gdMutexLock(x) tsrm_mutex_lock(x)
+#define gdMutexUnlock(x) tsrm_mutex_unlock(x)
+#else
+#define gdMutexDeclare(x)
+#define gdMutexSetup(x)
+#define gdMutexShutdown(x)
+#define gdMutexLock(x)
+#define gdMutexUnlock(x)
+#endif
+
+#endif /* GDHELPERS_H */
+