Skip to content

pgut.c--pgut_malloc #146

@WildGooseSouth

Description

@WildGooseSouth

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 *));`

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions