diff options
author | Mukund Sivaraman <muks@banu.com> | 2008-12-01 15:01:11 +0000 |
---|---|---|
committer | Mukund Sivaraman <muks@banu.com> | 2008-12-01 15:01:11 +0000 |
commit | a257703e59163b4f38c38f549179b8e45ac68c63 (patch) | |
tree | d056783c13f4adb25c133899f5d750a2b7123a2f /src/heap.c | |
parent | 448c19077c195fafd244539eeb5315773261fcaf (diff) |
Reformat code to GNU coding style
This is a commit which simply ran all C source code files
through GNU indent. No other modifications were made.
Diffstat (limited to 'src/heap.c')
-rw-r--r-- | src/heap.c | 135 |
1 files changed, 68 insertions, 67 deletions
@@ -28,71 +28,72 @@ #include "text.h" void * -debugging_calloc(size_t nmemb, size_t size, const char *file, - unsigned long line) +debugging_calloc (size_t nmemb, size_t size, const char *file, + unsigned long line) { - void *ptr; + void *ptr; - assert(nmemb > 0); - assert(size > 0); + assert (nmemb > 0); + assert (size > 0); - ptr = calloc(nmemb, size); - fprintf(stderr, "{calloc: %p:%zu x %zu} %s:%lu\n", ptr, nmemb, size, file, - line); - return ptr; + ptr = calloc (nmemb, size); + fprintf (stderr, "{calloc: %p:%zu x %zu} %s:%lu\n", ptr, nmemb, size, file, + line); + return ptr; } void * -debugging_malloc(size_t size, const char *file, unsigned long line) +debugging_malloc (size_t size, const char *file, unsigned long line) { - void *ptr; + void *ptr; - assert(size > 0); + assert (size > 0); - ptr = malloc(size); - fprintf(stderr, "{malloc: %p:%zu} %s:%lu\n", ptr, size, file, line); - return ptr; + ptr = malloc (size); + fprintf (stderr, "{malloc: %p:%zu} %s:%lu\n", ptr, size, file, line); + return ptr; } void * -debugging_realloc(void *ptr, size_t size, const char *file, unsigned long line) +debugging_realloc (void *ptr, size_t size, const char *file, + unsigned long line) { - void *newptr; + void *newptr; - assert(size > 0); + assert (size > 0); - newptr = realloc(ptr, size); - fprintf(stderr, "{realloc: %p -> %p:%zu} %s:%lu\n", ptr, newptr, size, - file, line); - return newptr; + newptr = realloc (ptr, size); + fprintf (stderr, "{realloc: %p -> %p:%zu} %s:%lu\n", ptr, newptr, size, + file, line); + return newptr; } void -debugging_free(void *ptr, const char *file, unsigned long line) +debugging_free (void *ptr, const char *file, unsigned long line) { - fprintf(stderr, "{free: %p} %s:%lu\n", ptr, file, line); + fprintf (stderr, "{free: %p} %s:%lu\n", ptr, file, line); - if (ptr != NULL) - free(ptr); - return; + if (ptr != NULL) + free (ptr); + return; } char * -debugging_strdup(const char *s, const char *file, unsigned long line) +debugging_strdup (const char *s, const char *file, unsigned long line) { - char *ptr; - size_t len; + char *ptr; + size_t len; - assert(s != NULL); + assert (s != NULL); - len = strlen(s) + 1; - ptr = malloc(len); - if (!ptr) - return NULL; - memcpy(ptr, s, len); + len = strlen (s) + 1; + ptr = malloc (len); + if (!ptr) + return NULL; + memcpy (ptr, s, len); - fprintf(stderr, "{strdup: %p:%zu} %s:%lu\n", ptr, len, file, line); - return ptr; + fprintf (stderr, "{strdup: %p:%zu} %s:%lu\n", ptr, len, file, line); + return ptr; } /* @@ -104,32 +105,32 @@ debugging_strdup(const char *s, const char *file, unsigned long line) * solution. */ void * -malloc_shared_memory(size_t size) +malloc_shared_memory (size_t size) { - int fd; - void *ptr; - char buffer[32]; + int fd; + void *ptr; + char buffer[32]; - static char *shared_file = "/tmp/tinyproxy.shared.XXXXXX"; + static char *shared_file = "/tmp/tinyproxy.shared.XXXXXX"; - assert(size > 0); + assert (size > 0); - strlcpy(buffer, shared_file, sizeof(buffer)); + strlcpy (buffer, shared_file, sizeof (buffer)); - /* Only allow u+rw bits. This may be required for some versions - * of glibc so that mkstemp() doesn't make us vulnerable. - */ - umask(0177); + /* Only allow u+rw bits. This may be required for some versions + * of glibc so that mkstemp() doesn't make us vulnerable. + */ + umask (0177); - if ((fd = mkstemp(buffer)) == -1) - return MAP_FAILED; - unlink(buffer); + if ((fd = mkstemp (buffer)) == -1) + return MAP_FAILED; + unlink (buffer); - if (ftruncate(fd, size) == -1) - return MAP_FAILED; - ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (ftruncate (fd, size) == -1) + return MAP_FAILED; + ptr = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - return ptr; + return ptr; } /* @@ -137,21 +138,21 @@ malloc_shared_memory(size_t size) * zero. */ void * -calloc_shared_memory(size_t nmemb, size_t size) +calloc_shared_memory (size_t nmemb, size_t size) { - void *ptr; - long length; + void *ptr; + long length; - assert(nmemb > 0); - assert(size > 0); + assert (nmemb > 0); + assert (size > 0); - length = nmemb * size; + length = nmemb * size; - ptr = malloc_shared_memory(length); - if (ptr == MAP_FAILED) - return ptr; + ptr = malloc_shared_memory (length); + if (ptr == MAP_FAILED) + return ptr; - memset(ptr, 0, length); + memset (ptr, 0, length); - return ptr; + return ptr; } |