Skip to content

Commit 9acb855

Browse files
committed
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.
1 parent 3b76733 commit 9acb855

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/backend/utils/mmgr/dsa.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,22 @@ dsa_allocate(dsa_area *area, Size size)
755755
return alloc_object(area, size_class);
756756
}
757757

758+
/*
759+
* As dsa_allocate, but zeroes the allocated memory.
760+
*/
761+
dsa_pointer
762+
dsa_allocate0(dsa_area *area, Size size)
763+
{
764+
dsa_pointer dp;
765+
char *object;
766+
767+
dp = dsa_allocate(area, size);
768+
object = dsa_get_address(area, dp);
769+
memset(object, 0, size);
770+
771+
return dp;
772+
}
773+
758774
/*
759775
* Free memory obtained with dsa_allocate.
760776
*/

src/include/utils/dsa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern void dsa_set_size_limit(dsa_area *area, Size limit);
106106
extern Size dsa_minimum_size(void);
107107
extern dsa_handle dsa_get_handle(dsa_area *area);
108108
extern dsa_pointer dsa_allocate(dsa_area *area, Size size);
109+
extern dsa_pointer dsa_allocate0(dsa_area *area, Size size);
109110
extern void dsa_free(dsa_area *area, dsa_pointer dp);
110111
extern void *dsa_get_address(dsa_area *area, dsa_pointer dp);
111112
extern void dsa_trim(dsa_area *area);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy