]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: memory: remove dead code
authorWilly Tarreau <w@1wt.eu>
Tue, 23 Dec 2014 12:51:28 +0000 (13:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Dec 2014 22:47:31 +0000 (23:47 +0100)
The very old pool managment code has not been used for the last 7 years
and is still polluting the file. Get rid of it now.

include/common/memory.h

index e446d81b60bca6634333f1f232872db78c501c12..80fa586cb6932458ff63ac90d74a1b3d27765281 100644 (file)
@@ -1,23 +1,23 @@
 /*
-  include/common/memory.h
-  Memory management definitions..
-
 Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation, version 2.1
-  exclusively.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
* include/common/memory.h
* Memory management definitions..
+ *
* Copyright (C) 2000-2014 Willy Tarreau - w@1wt.eu
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 #ifndef _COMMON_MEMORY_H
 #define _COMMON_MEMORY_H
 #include <common/config.h>
 #include <common/mini-clist.h>
 
-/*
- * Returns a pointer to an area of <__len> bytes taken from the pool <pool> or
- * dynamically allocated. In the first case, <__pool> is updated to point to
- * the next element in the list.
- */
-#define pool_alloc_from(__pool, __len)                      \
-({                                                          \
-        void *__p;                                          \
-        if ((__p = (__pool)) == NULL)                       \
-                __p = malloc(((__len) >= sizeof (void *)) ? \
-                      (__len) : sizeof(void *));            \
-        else {                                              \
-                (__pool) = *(void **)(__pool);             \
-        }                                                   \
-        __p;                                                \
-})
-
-/*
- * Puts a memory area back to the corresponding pool.
- * Items are chained directly through a pointer that
- * is written in the beginning of the memory area, so
- * there's no need for any carrier cell. This implies
- * that each memory area is at least as big as one
- * pointer.
- */
-#define pool_free_to(__pool, __ptr)             \
-({                                              \
-        *(void **)(__ptr) = (void *)(__pool);   \
-        __pool = (void *)(__ptr);               \
-})
-
-
-#ifdef  CONFIG_HAP_MEM_OPTIM
-/*
- * Returns a pointer to type <type> taken from the
- * pool <pool_type> or dynamically allocated. In the
- * first case, <pool_type> is updated to point to the
- * next element in the list.
- */
-#define pool_alloc(type)                                \
-({                                                      \
-        void *__p;                                      \
-        if ((__p = pool_##type) == NULL)                \
-                __p = malloc(sizeof_##type);            \
-        else {                                          \
-                pool_##type = *(void **)pool_##type;   \
-        }                                               \
-        __p;                                            \
-})
-
-/*
- * Puts a memory area back to the corresponding pool.
- * Items are chained directly through a pointer that
- * is written in the beginning of the memory area, so
- * there's no need for any carrier cell. This implies
- * that each memory area is at least as big as one
- * pointer.
- */
-#define pool_free(type, ptr)                            \
-({                                                      \
-        *(void **)(ptr) = (void *)pool_##type;         \
-        pool_##type = (void *)(ptr);                   \
-})
-
-#else
-#define pool_alloc(type) (calloc(1,sizeof_##type))
-#define pool_free(type, ptr) (free(ptr))
-#endif /* CONFIG_HAP_MEM_OPTIM */
-
-/*
- * This function destroys a pull by freeing it completely.
- * This should be called only under extreme circumstances.
- */
-static inline void pool_destroy(void **pool)
-{
-       void *temp, *next;
-       next = pool;
-       while (next) {
-               temp = next;
-               next = *(void **)temp;
-               free(temp);
-       }
-}
-
-
-/******* pools version 2 ********/
-
 #define MEM_F_SHARED   0x1
 
 struct pool_head {
@@ -132,6 +45,21 @@ struct pool_head {
 /* poison each newly allocated area with this byte if not null */
 extern char mem_poison_byte;
 
+/*
+ * This function destroys a pull by freeing it completely.
+ * This should be called only under extreme circumstances.
+ */
+static inline void pool_destroy(void **pool)
+{
+       void *temp, *next;
+       next = pool;
+       while (next) {
+               temp = next;
+               next = *(void **)temp;
+               free(temp);
+       }
+}
+
 /* Allocate a new entry for pool <pool>, and return it for immediate use.
  * NULL is returned if no memory is available for a new creation.
  */