diff options
| author | Rasmus Lerdorf <rasmus@php.net> | 2002-04-13 02:03:09 +0000 |
|---|---|---|
| committer | Rasmus Lerdorf <rasmus@php.net> | 2002-04-13 02:03:09 +0000 |
| commit | 7a8cade379e90bafca21cd983f2f5a4d84a7ff8a (patch) | |
| tree | 3ad6b2f42fd690dd7acdf04a41173471f27b5ea7 /ext/gd/libgd/gdhelpers.c | |
| parent | c46199f5b98c35b911d18eb6a9646ccb118d46ef (diff) | |
| download | php-git-7a8cade379e90bafca21cd983f2f5a4d84a7ff8a.tar.gz | |
Initial commit of the built-in libgd based on GD-2.0.1
This initial checkin has no changes to any of the libgd code so it can
be used as a basis for diffs. It also will not build currently because
of this. The PHP gd checks need to be incorporated along with a bit of
other config magic. It also shouldn't break the build and will only
take effect if you use --with-gd=php right now.
Diffstat (limited to 'ext/gd/libgd/gdhelpers.c')
| -rw-r--r-- | ext/gd/libgd/gdhelpers.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/ext/gd/libgd/gdhelpers.c b/ext/gd/libgd/gdhelpers.c new file mode 100644 index 0000000000..7909ca0ee2 --- /dev/null +++ b/ext/gd/libgd/gdhelpers.c @@ -0,0 +1,95 @@ +#include "gd.h" +#include "gdhelpers.h" +#include <stdlib.h> + +/* TBB: gd_strtok_r is not portable; provide an implementation */ + +#define SEP_TEST (separators[*((unsigned char *) s)]) + +char * +gd_strtok_r (char *s, char *sep, char **state) +{ + char separators[256]; + char *start; + char *result = 0; + memset (separators, 0, sizeof (separators)); + while (*sep) + { + separators[*((unsigned char *) sep)] = 1; + sep++; + } + if (!s) + { + /* Pick up where we left off */ + s = *state; + } + start = s; + /* 1. EOS */ + if (!(*s)) + { + *state = s; + return 0; + } + /* 2. Leading separators, if any */ + if (SEP_TEST) + { + do + { + s++; + } + while (SEP_TEST); + /* 2a. EOS after separators only */ + if (!(*s)) + { + *state = s; + return 0; + } + } + /* 3. A token */ + result = s; + do + { + /* 3a. Token at end of string */ + if (!(*s)) + { + *state = s; + return result; + } + s++; + } + while (!SEP_TEST); + /* 4. Terminate token and skip trailing separators */ + *s = '\0'; + do + { + s++; + } + while (SEP_TEST); + /* 5. Return token */ + *state = s; + return result; +} + +void * +gdCalloc (size_t nmemb, size_t size) +{ + return calloc (nmemb, size); +} + +void * +gdMalloc (size_t size) +{ + return malloc (size); +} + +void * +gdRealloc (void *ptr, size_t size) +{ + return realloc (ptr, size); +} + +void +gdFree (void *ptr) +{ + free (ptr); +} |
