diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-02-16 12:45:53 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-02-16 12:57:03 -0500 |
commit | 9acb85597f1223ac26a5b19a9345849c43d0ff54 (patch) | |
tree | 1c468fd79b52034d616a562d5a9f0ef0c96f3381 /src/backend/utils/mmgr/dsa.c | |
parent | 3b7673388da3598933ae6c4f9fdc7c79dee05558 (diff) | |
download | postgresql-9acb85597f1223ac26a5b19a9345849c43d0ff54.tar.gz postgresql-9acb85597f1223ac26a5b19a9345849c43d0ff54.zip |
Add new function dsa_allocate0.
This does the same thing as dsa_allocate, except that the memory
is guaranteed to be zero-filled on return.
Dilip Kumar, adjusted by me.
Diffstat (limited to 'src/backend/utils/mmgr/dsa.c')
-rw-r--r-- | src/backend/utils/mmgr/dsa.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/backend/utils/mmgr/dsa.c b/src/backend/utils/mmgr/dsa.c index 7dc43f1ea79..3eb3d4d9a4e 100644 --- a/src/backend/utils/mmgr/dsa.c +++ b/src/backend/utils/mmgr/dsa.c @@ -756,6 +756,22 @@ dsa_allocate(dsa_area *area, Size size) } /* + * As dsa_allocate, but zeroes the allocated memory. + */ +dsa_pointer +dsa_allocate0(dsa_area *area, Size size) +{ + dsa_pointer dp; + char *object; + + dp = dsa_allocate(area, size); + object = dsa_get_address(area, dp); + memset(object, 0, size); + + return dp; +} + +/* * Free memory obtained with dsa_allocate. */ void |