mirror of
https://github.com/postgres/postgres.git
synced 2025-05-22 00:02:02 -04:00
34 lines
498 B
C
34 lines
498 B
C
#include <ecpgtype.h>
|
|
#include <ecpglib.h>
|
|
|
|
char *
|
|
ecpg_alloc(long size, int lineno)
|
|
{
|
|
char *new = (char *) calloc(1L, size);
|
|
|
|
if (!new)
|
|
{
|
|
ECPGlog("out of memory\n");
|
|
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
|
|
return NULL;
|
|
}
|
|
|
|
memset(new, '\0', size);
|
|
return (new);
|
|
}
|
|
|
|
char *
|
|
ecpg_strdup(const char *string, int lineno)
|
|
{
|
|
char *new = strdup(string);
|
|
|
|
if (!new)
|
|
{
|
|
ECPGlog("out of memory\n");
|
|
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
|
|
return NULL;
|
|
}
|
|
|
|
return (new);
|
|
}
|