|
Adam Tkac |
b59841 |
diff -up bind-9.5.0a6/lib/dns/spnego.c.memory_management bind-9.5.0a6/lib/dns/spnego.c
|
|
Adam Tkac |
b59841 |
--- bind-9.5.0a6/lib/dns/spnego.c.memory_management 2007-08-13 17:59:03.000000000 +0200
|
|
Adam Tkac |
b59841 |
+++ bind-9.5.0a6/lib/dns/spnego.c 2007-08-13 17:59:44.000000000 +0200
|
|
Adam Tkac |
b59841 |
@@ -169,88 +169,6 @@
|
|
Adam Tkac |
b59841 |
*/
|
|
Adam Tkac |
b59841 |
#include "spnego.h"
|
|
Adam Tkac |
b59841 |
|
|
Adam Tkac |
b59841 |
-/*
|
|
Adam Tkac |
b59841 |
- * The isc_mem function keep track of allocation sizes, but we can't
|
|
Adam Tkac |
b59841 |
- * get at that information, and we need to know sizes to implement a
|
|
Adam Tkac |
b59841 |
- * realloc() clone. So we use a little more memory to keep track of
|
|
Adam Tkac |
b59841 |
- * sizes allocated here.
|
|
Adam Tkac |
b59841 |
- *
|
|
Adam Tkac |
b59841 |
- * These functions follow Harbison & Steele, 4th edition, particularly
|
|
Adam Tkac |
b59841 |
- * with regard to realloc()'s behavior.
|
|
Adam Tkac |
b59841 |
- */
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
-static void *
|
|
Adam Tkac |
b59841 |
-spnego_malloc(size_t size, const char *file, int line)
|
|
Adam Tkac |
b59841 |
-{
|
|
Adam Tkac |
b59841 |
- char *p;
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- if (size == 0)
|
|
Adam Tkac |
b59841 |
- return (NULL);
|
|
Adam Tkac |
b59841 |
- p = isc_mem_allocate(dst__memory_pool, size + sizeof(size_t));
|
|
Adam Tkac |
b59841 |
- if (p == NULL)
|
|
Adam Tkac |
b59841 |
- return NULL;
|
|
Adam Tkac |
b59841 |
- *(size_t *)p = size;
|
|
Adam Tkac |
b59841 |
- p += sizeof(size_t);
|
|
Adam Tkac |
b59841 |
-#ifdef SPNEGO_ALLOC_DEBUG
|
|
Adam Tkac |
b59841 |
- printf("spnego_malloc(%lu) %lx %s %u\n",
|
|
Adam Tkac |
b59841 |
- (unsigned long) size, (unsigned long) p, file, line);
|
|
Adam Tkac |
b59841 |
-#else
|
|
Adam Tkac |
b59841 |
- (void)file;
|
|
Adam Tkac |
b59841 |
- (void)line;
|
|
Adam Tkac |
b59841 |
-#endif
|
|
Adam Tkac |
b59841 |
- return (p);
|
|
Adam Tkac |
b59841 |
-}
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
-static void
|
|
Adam Tkac |
b59841 |
-spnego_free(void *ptr, const char *file, int line)
|
|
Adam Tkac |
b59841 |
-{
|
|
Adam Tkac |
b59841 |
- char *p = ptr;
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- if (p == NULL)
|
|
Adam Tkac |
b59841 |
- return;
|
|
Adam Tkac |
b59841 |
-#ifdef SPNEGO_ALLOC_DEBUG
|
|
Adam Tkac |
b59841 |
- printf("spnego_free(%lx) %s %u\n",
|
|
Adam Tkac |
b59841 |
- (unsigned long) p, file, line);
|
|
Adam Tkac |
b59841 |
-#else
|
|
Adam Tkac |
b59841 |
- (void)file;
|
|
Adam Tkac |
b59841 |
- (void)line;
|
|
Adam Tkac |
b59841 |
-#endif
|
|
Adam Tkac |
b59841 |
- p -= sizeof(size_t);
|
|
Adam Tkac |
b59841 |
- isc_mem_free(dst__memory_pool, p);
|
|
Adam Tkac |
b59841 |
-}
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
-static void *
|
|
Adam Tkac |
b59841 |
-spnego_realloc(void *old_ptr, size_t new_size, const char *file, int line)
|
|
Adam Tkac |
b59841 |
-{
|
|
Adam Tkac |
b59841 |
- size_t *old_size;
|
|
Adam Tkac |
b59841 |
- void *new_ptr;
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- if (old_ptr == NULL)
|
|
Adam Tkac |
b59841 |
- return (spnego_malloc(new_size, file, line));
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- if (new_size == 0) {
|
|
Adam Tkac |
b59841 |
- spnego_free(old_ptr, file, line);
|
|
Adam Tkac |
b59841 |
- return (NULL);
|
|
Adam Tkac |
b59841 |
- }
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- old_size = old_ptr;
|
|
Adam Tkac |
b59841 |
- old_size--;
|
|
Adam Tkac |
b59841 |
- if (*old_size >= new_size)
|
|
Adam Tkac |
b59841 |
- return (old_ptr);
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- new_ptr = spnego_malloc(new_size, file, line);
|
|
Adam Tkac |
b59841 |
- if (new_ptr == NULL)
|
|
Adam Tkac |
b59841 |
- return (NULL);
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
- memcpy(new_ptr, old_ptr, *old_size);
|
|
Adam Tkac |
b59841 |
- spnego_free(old_ptr, file, line);
|
|
Adam Tkac |
b59841 |
- return (new_ptr);
|
|
Adam Tkac |
b59841 |
-}
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
-#define malloc(x) spnego_malloc(x, __FILE__, __LINE__)
|
|
Adam Tkac |
b59841 |
-#define free(x) spnego_free(x, __FILE__, __LINE__)
|
|
Adam Tkac |
b59841 |
-#define realloc(x,y) spnego_realloc(x, y, __FILE__, __LINE__)
|
|
Adam Tkac |
b59841 |
-
|
|
Adam Tkac |
b59841 |
/* asn1_err.h */
|
|
Adam Tkac |
b59841 |
/* Generated from ../../../lib/asn1/asn1_err.et */
|
|
Adam Tkac |
b59841 |
|