1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

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.
This commit is contained in:
Robert Haas
2017-02-16 12:45:53 -05:00
parent 3b7673388d
commit 9acb85597f
2 changed files with 17 additions and 0 deletions

View File

@@ -755,6 +755,22 @@ dsa_allocate(dsa_area *area, Size size)
return alloc_object(area, size_class);
}
/*
* 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.
*/