summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2007-03-22 18:57:52 +0000
committerAlvaro Herrera2007-03-22 18:57:52 +0000
commit105d97f6686c0661e8eb10c9f5c0cb7c257079b9 (patch)
tree31edd2095cbc4ba1234ae5d48f4f31fe124e8d49
parentf4061aa2333f48325a84c41cba174b6c90abad1a (diff)
Remove the currently unused FRONTEND case in dllist.c. This allows the usage
of palloc instead of malloc, which means a list can be freed simply by deleting the memory context that contains it.
-rw-r--r--src/backend/lib/dllist.c42
1 files changed, 7 insertions, 35 deletions
diff --git a/src/backend/lib/dllist.c b/src/backend/lib/dllist.c
index 9d075c4f7c..cd6fe5948a 100644
--- a/src/backend/lib/dllist.c
+++ b/src/backend/lib/dllist.c
@@ -13,15 +13,7 @@
*
*-------------------------------------------------------------------------
*/
-
-/* can be used in frontend or backend */
-#ifdef FRONTEND
-#include "postgres_fe.h"
-/* No assert checks in frontend ... */
-#define Assert(condition)
-#else
#include "postgres.h"
-#endif
#include "lib/dllist.h"
@@ -31,18 +23,8 @@ DLNewList(void)
{
Dllist *l;
- l = (Dllist *) malloc(sizeof(Dllist));
- if (l == NULL)
- {
-#ifdef FRONTEND
- fprintf(stderr, "memory exhausted in DLNewList\n");
- exit(1);
-#else
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
-#endif
- }
+ l = (Dllist *) palloc(sizeof(Dllist));
+
l->dll_head = NULL;
l->dll_tail = NULL;
@@ -66,9 +48,9 @@ DLFreeList(Dllist *list)
Dlelem *curr;
while ((curr = DLRemHead(list)) != NULL)
- free(curr);
+ pfree(curr);
- free(list);
+ pfree(list);
}
Dlelem *
@@ -76,18 +58,8 @@ DLNewElem(void *val)
{
Dlelem *e;
- e = (Dlelem *) malloc(sizeof(Dlelem));
- if (e == NULL)
- {
-#ifdef FRONTEND
- fprintf(stderr, "memory exhausted in DLNewElem\n");
- exit(1);
-#else
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
-#endif
- }
+ e = (Dlelem *) palloc(sizeof(Dlelem));
+
e->dle_next = NULL;
e->dle_prev = NULL;
e->dle_val = val;
@@ -107,7 +79,7 @@ DLInitElem(Dlelem *e, void *val)
void
DLFreeElem(Dlelem *e)
{
- free(e);
+ pfree(e);
}
void