Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgut.c--pgut_malloc #146

Open
WildGooseSouth opened this issue Sep 28, 2020 · 0 comments
Open

pgut.c--pgut_malloc #146

WildGooseSouth opened this issue Sep 28, 2020 · 0 comments
Assignees

Comments

@WildGooseSouth
Copy link

WildGooseSouth commented Sep 28, 2020

In pgut_malloc function, it call malloc function to resuqest memory. Whether it will need call memset function to initialize the requested memeory.

`void *
pgut_malloc(size_t size)
{
char *ret;

if ((ret = malloc(size)) == NULL)
	ereport(ERROR,
		(errcode(ERROR_NOMEM),
		 errmsg("could not allocate memory (%lu bytes): %s",
			(unsigned long) size, strerror(errno))));
return ret;

}`

Like the function pgut_realloc function usage.

`p = pgut_realloc(array->data, sizeof(void *) * newsize);

/* initialize expanded area to NULL */
memset(p + array->alloced, 0, (newsize - array->alloced) * sizeof(void *));`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants