Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
78822b32
Commit
78822b32
authored
Nov 10, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add palloc0 function to inline MemSet for newNode call.
parent
7aeab94a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
20 deletions
+49
-20
src/backend/nodes/nodes.c
src/backend/nodes/nodes.c
+2
-12
src/backend/utils/mmgr/mcxt.c
src/backend/utils/mmgr/mcxt.c
+24
-1
src/include/nodes/nodes.h
src/include/nodes/nodes.h
+19
-6
src/include/utils/palloc.h
src/include/utils/palloc.h
+4
-1
No files found.
src/backend/nodes/nodes.c
View file @
78822b32
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.1
7 2002/10/11 04:16:44
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.1
8 2002/11/10 02:17:25
momjian Exp $
*
* HISTORY
* Andrew Yu Oct 20, 1994 file creation
...
...
@@ -28,15 +28,5 @@
* macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
*
*/
Node
*
newNode
(
Size
size
,
NodeTag
tag
)
{
Node
*
newNode
;
Node
*
newNodeMacroHolder
;
Assert
(
size
>=
sizeof
(
Node
));
/* need the tag, at least */
newNode
=
(
Node
*
)
palloc
(
size
);
MemSet
((
char
*
)
newNode
,
0
,
size
);
newNode
->
type
=
tag
;
return
newNode
;
}
src/backend/utils/mmgr/mcxt.c
View file @
78822b32
...
...
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.3
4 2002/10/11 04:16:44
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.3
5 2002/11/10 02:17:25
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -452,6 +452,29 @@ MemoryContextAlloc(MemoryContext context, Size size)
return
(
*
context
->
methods
->
alloc
)
(
context
,
size
);
}
/*
* MemoryContextAllocZero
* Like MemoryContextAlloc, but clears allocated memory
*
* We could just call MemoryContextAlloc then clear the memory, but this
* function is called too many times, so we have a separate version.
*/
void
*
MemoryContextAllocZero
(
MemoryContext
context
,
Size
size
)
{
void
*
ret
;
AssertArg
(
MemoryContextIsValid
(
context
));
if
(
!
AllocSizeIsValid
(
size
))
elog
(
ERROR
,
"MemoryContextAllocZero: invalid request size %lu"
,
(
unsigned
long
)
size
);
ret
=
(
*
context
->
methods
->
alloc
)
(
context
,
size
);
MemSet
(
ret
,
0
,
size
);
return
ret
;
}
/*
* pfree
* Release an allocated chunk.
...
...
src/include/nodes/nodes.h
View file @
78822b32
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.12
1 2002/11/06 00:00:44 tgl
Exp $
* $Id: nodes.h,v 1.12
2 2002/11/10 02:17:25 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -262,6 +262,24 @@ typedef struct Node
#define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
/*
* There is no way to dereference the palloc'ed pointer to assign the
* tag, and return the pointer itself, so we need a holder variable.
* Fortunately, this function isn't recursive so we just define
* a global variable for this purpose.
*/
extern
Node
*
newNodeMacroHolder
;
#define newNode(size, tag) \
( \
AssertMacro((size) >= sizeof(Node)),
/* need the tag, at least */
\
\
newNodeMacroHolder = (Node *) palloc0(size), \
newNodeMacroHolder->type = (tag), \
newNodeMacroHolder \
)
#define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
#define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
...
...
@@ -283,11 +301,6 @@ typedef struct Node
* ----------------------------------------------------------------
*/
/*
* nodes/nodes.c
*/
extern
Node
*
newNode
(
Size
size
,
NodeTag
tag
);
/*
* nodes/{outfuncs.c,print.c}
*/
...
...
src/include/utils/palloc.h
View file @
78822b32
...
...
@@ -21,7 +21,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: palloc.h,v 1.2
1 2002/10/11 04:16:44
momjian Exp $
* $Id: palloc.h,v 1.2
2 2002/11/10 02:17:25
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -46,9 +46,12 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext;
* Fundamental memory-allocation operations (more are in utils/memutils.h)
*/
extern
void
*
MemoryContextAlloc
(
MemoryContext
context
,
Size
size
);
extern
void
*
MemoryContextAllocZero
(
MemoryContext
context
,
Size
size
);
#define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz))
#define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz))
extern
void
pfree
(
void
*
pointer
);
extern
void
*
repalloc
(
void
*
pointer
,
Size
size
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment