summaryrefslogtreecommitdiff
path: root/src/backend/utils/mmgr/palloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/mmgr/palloc.c')
-rw-r--r--src/backend/utils/mmgr/palloc.c90
1 files changed, 9 insertions, 81 deletions
diff --git a/src/backend/utils/mmgr/palloc.c b/src/backend/utils/mmgr/palloc.c
index 9c50c3a3023..ad4e506f2fa 100644
--- a/src/backend/utils/mmgr/palloc.c
+++ b/src/backend/utils/mmgr/palloc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.9 1999/01/17 03:04:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.10 1999/02/06 16:50:27 wieck Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,98 +22,26 @@
#include "nodes/memnodes.h"
-#include "utils/palloc.h"
/* ----------------------------------------------------------------
* User library functions
* ----------------------------------------------------------------
*/
-#undef palloc
-#undef pfree
-#undef MemoryContextAlloc
-#undef MemoryContextFree
-#undef malloc
-#undef free
-
-/* define PALLOC_IS_MALLOC if you want palloc to go straight to the
- raw malloc, without concern for the extra bookkeeping needed to
- ensure garbage is collected at the end of transactions - jolly 1/12/94 */
-
-
-/*
- * palloc --
- * Returns pointer to aligned memory of specified size.
- *
- * Exceptions:
- * BadArgument if size < 1 or size >= MaxAllocSize.
- * ExhaustedMemory if allocation fails.
- * NonallocatedPointer if pointer was not returned by palloc or repalloc
- * or may have been freed already.
- *
- * pfree --
- * Frees memory associated with pointer returned from palloc or repalloc.
- *
- * Exceptions:
- * BadArgument if pointer is invalid.
- * FreeInWrongContext if pointer was allocated in a different "context."
- * NonallocatedPointer if pointer was not returned by palloc or repalloc
- * or may have been subsequently freed.
+/* ----------
+ * palloc(), pfree() and repalloc() are now macros in palloc.h
+ * ----------
*/
-void *
-palloc(Size size)
-{
-#ifdef PALLOC_IS_MALLOC
- return malloc(size);
-#else
- return MemoryContextAlloc(CurrentMemoryContext, size);
-#endif /* PALLOC_IS_MALLOC */
-}
-void
-pfree(void *pointer)
-{
-#ifdef PALLOC_IS_MALLOC
- free(pointer);
-#else
- MemoryContextFree(CurrentMemoryContext, pointer);
-#endif /* PALLOC_IS_MALLOC */
-}
-
-/*
- * repalloc --
- * Returns pointer to aligned memory of specified size.
- *
- * Side effects:
- * The returned memory is first filled with the contents of *pointer
- * up to the minimum of size and psize(pointer). Pointer is freed.
- *
- * Exceptions:
- * BadArgument if pointer is invalid or size < 1 or size >= MaxAllocSize.
- * ExhaustedMemory if allocation fails.
- * NonallocatedPointer if pointer was not returned by palloc or repalloc
- * or may have been freed already.
- */
-void *
-repalloc(void *pointer, Size size)
-{
-#ifdef PALLOC_IS_MALLOC
- return realloc(pointer, size);
-#else
- return MemoryContextRealloc(CurrentMemoryContext, pointer, size);
-#endif
-}
-
-/* pstrdup
- allocates space for and copies a string
- just like strdup except it uses palloc instead of malloc */
char *
pstrdup(char *string)
{
- char *nstr;
+ char *nstr;
+ int len;
- nstr = (char *) palloc(strlen(string) + 1);
- strcpy(nstr, string);
+ nstr = palloc(len = strlen(string) + 1);
+ MemoryCopy(nstr, string, len);
return nstr;
}
+