Source

gd-libgd / src / gdhelpers.h

#ifndef GDHELPERS_H
#define GDHELPERS_H 1

/* sys/types.h is needed for size_t on Sparc-SunOS-4.1 */
#include <sys/types.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(). */
void *gdCalloc (size_t nmemb, size_t size);
void *gdMalloc (size_t size);
void *gdRealloc (void *ptr, size_t size);

/* 2.0.16: portable mutex support for thread safety. */

#ifdef WIN32
#define gdMutexDeclare(x) CRITICAL_SECTION x
#define gdMutexSetup(x) InitializeCriticalSection(&x)
#define gdMutexShutdown(x) DeleteCriticalSection(&x)
#define gdMutexLock(x) EnterCriticalSection(&x)
#define gdMutexUnlock(x) LeaveCriticalSection(&x)
#else
#ifdef HAVE_PTHREAD
#include <pthread.h>
#define gdMutexDeclare(x) pthread_mutex_t x
#define gdMutexSetup(x) pthread_mutex_init(&x, 0)
#define gdMutexShutdown(x) pthread_mutex_destroy(&x)
#define gdMutexLock(x) pthread_mutex_lock(&x)
#define gdMutexUnlock(x) pthread_mutex_unlock(&x)
#else
#define gdMutexDeclare(x)
#define gdMutexSetup(x) 
#define gdMutexShutdown(x) 
#define gdMutexLock(x) 
#define gdMutexUnlock(x) 
#endif /* HAVE_PTHREAD */
#endif /* WIN32 */

#endif /* GDHELPERS_H */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.