Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9acb855

Browse files
committed
Add new function dsa_allocate0.
This does the same thing as dsa_allocate, except that the memoryis guaranteed to be zero-filled on return.Dilip Kumar, adjusted by me.
1 parent3b76733 commit9acb855

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
returnalloc_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,Sizesize)
763+
{
764+
dsa_pointerdp;
765+
char*object;
766+
767+
dp=dsa_allocate(area,size);
768+
object=dsa_get_address(area,dp);
769+
memset(object,0,size);
770+
771+
returndp;
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
externSizedsa_minimum_size(void);
107107
externdsa_handledsa_get_handle(dsa_area*area);
108108
externdsa_pointerdsa_allocate(dsa_area*area,Sizesize);
109+
externdsa_pointerdsa_allocate0(dsa_area*area,Sizesize);
109110
externvoiddsa_free(dsa_area*area,dsa_pointerdp);
110111
externvoid*dsa_get_address(dsa_area*area,dsa_pointerdp);
111112
externvoiddsa_trim(dsa_area*area);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp