diff options
author | Mukund Sivaraman <muks@banu.com> | 2009-09-15 01:11:25 +0530 |
---|---|---|
committer | Mukund Sivaraman <muks@banu.com> | 2009-09-15 01:11:25 +0530 |
commit | 7b9234f394b688991a5b601ff1e487a19de29870 (patch) | |
tree | ccdb923e457666c174311bdf0f2ca4370e27e70c /src/heap.c | |
parent | 2cb677759236fe54c24c1ce099a61f54bace3f73 (diff) | |
download | tinyproxy-7b9234f394b688991a5b601ff1e487a19de29870.tar.gz tinyproxy-7b9234f394b688991a5b601ff1e487a19de29870.zip |
Indent code to Tinyproxy coding style
The modified files were indented with GNU indent using the
following command:
indent -npro -kr -i8 -ts8 -sob -l80 -ss -cs -cp1 -bs -nlps -nprs -pcs \
-saf -sai -saw -sc -cdw -ce -nut -il0
No other changes of any sort were made.
Diffstat (limited to '')
-rw-r--r-- | src/heap.c | 143 |
1 files changed, 68 insertions, 75 deletions
@@ -27,73 +27,68 @@ #include "heap.h" #include "text.h" -void * -debugging_calloc (size_t nmemb, size_t size, const char *file, - unsigned long line) +void *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) +void *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) +void *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) +void 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) +char *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 = (char *)malloc (len); - if (!ptr) - return NULL; - memcpy (ptr, s, len); + len = strlen (s) + 1; + ptr = (char *) 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,55 +99,53 @@ debugging_strdup (const char *s, const char *file, unsigned long line) * want to look into something like MM (Shared Memory Library) for a better * solution. */ -void * -malloc_shared_memory (size_t size) +void *malloc_shared_memory (size_t size) { - int fd; - void *ptr; - char buffer[32]; + int fd; + void *ptr; + char buffer[32]; - static const char *shared_file = "/tmp/tinyproxy.shared.XXXXXX"; + static const 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; } /* * Allocate a block of memory from the "shared" region an initialize it to * zero. */ -void * -calloc_shared_memory (size_t nmemb, size_t size) +void *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; } |