diff options
Diffstat (limited to 'src/interfaces/ecpg/lib/memory.c')
-rw-r--r-- | src/interfaces/ecpg/lib/memory.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/lib/memory.c b/src/interfaces/ecpg/lib/memory.c new file mode 100644 index 00000000000..61c5d299f37 --- /dev/null +++ b/src/interfaces/ecpg/lib/memory.c @@ -0,0 +1,33 @@ +#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); +} |