#include "postgres_fe.h"
#include "ecpg-pthread-win32.h"
#include "ecpgtype.h"
#include "ecpglib.h"
#include "ecpgerrno.h"
#include "extern.h"
Go to the source code of this file.
Data Structures | |
struct | auto_mem |
Defines | |
#define | POSTGRES_ECPG_INTERNAL |
#define | get_auto_allocs() (auto_allocs) |
#define | set_auto_allocs(am) do { auto_allocs = (am); } while(0) |
Functions | |
void | ecpg_free (void *ptr) |
char * | ecpg_alloc (long size, int lineno) |
char * | ecpg_realloc (void *ptr, long size, int lineno) |
char * | ecpg_strdup (const char *string, int lineno) |
void | ecpg_add_mem (void *ptr, int lineno) |
void | ECPGfree_auto_mem (void) |
void | ecpg_clear_auto_mem (void) |
Variables | |
static struct auto_mem * | auto_allocs = NULL |
#define get_auto_allocs | ( | ) | (auto_allocs) |
Definition at line 103 of file memory.c.
Referenced by ecpg_add_mem(), ecpg_clear_auto_mem(), and ECPGfree_auto_mem().
#define set_auto_allocs | ( | am | ) | do { auto_allocs = (am); } while(0) |
Definition at line 104 of file memory.c.
Referenced by ecpg_add_mem(), ecpg_clear_auto_mem(), and ECPGfree_auto_mem().
void ecpg_add_mem | ( | void * | ptr, | |
int | lineno | |||
) |
Definition at line 108 of file memory.c.
References ecpg_alloc(), get_auto_allocs, auto_mem::next, auto_mem::pointer, and set_auto_allocs.
Referenced by ecpg_store_result(), and ECPGget_desc().
{ struct auto_mem *am = (struct auto_mem *) ecpg_alloc(sizeof(struct auto_mem), lineno); am->pointer = ptr; am->next = get_auto_allocs(); set_auto_allocs(am); }
char* ecpg_alloc | ( | long | size, | |
int | lineno | |||
) |
Definition at line 19 of file memory.c.
References calloc, ECPG_OUT_OF_MEMORY, ecpg_raise(), ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, and NULL.
Referenced by deallocate_one(), ecpg_add_mem(), ecpg_build_compat_sqlda(), ecpg_build_native_sqlda(), ecpg_execute(), ecpg_get_data(), ecpg_is_type_an_array(), ecpg_store_input(), ecpg_store_result(), ecpg_type_infocache_push(), ECPGallocate_desc(), ECPGconnect(), ECPGdo(), ECPGget_desc(), ECPGset_desc(), insert_tobeinserted(), prepare_common(), quote_postgres(), and replace_variables().
{ char *new = (char *) calloc(1L, size); if (!new) { ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); return NULL; } return (new); }
void ecpg_clear_auto_mem | ( | void | ) |
Definition at line 138 of file memory.c.
References ecpg_free(), get_auto_allocs, auto_mem::next, NULL, and set_auto_allocs.
Referenced by ECPGconnect(), and ECPGdo().
{ struct auto_mem *am = get_auto_allocs(); /* only free our own structure */ if (am) { do { struct auto_mem *act = am; am = am->next; ecpg_free(act); } while (am); set_auto_allocs(NULL); } }
void ecpg_free | ( | void * | ptr | ) |
Definition at line 13 of file memory.c.
References free.
Referenced by deallocate_one(), descriptor_free(), ecpg_clear_auto_mem(), ecpg_execute(), ecpg_finish(), ecpg_freeStmtCacheEntry(), ecpg_is_type_an_array(), ecpg_store_input(), ECPGallocate_desc(), ECPGconnect(), ECPGdo(), ECPGfree_auto_mem(), ECPGget_desc(), ECPGset_desc(), free_params(), free_statement(), free_variable(), insert_tobeinserted(), prepare_common(), quote_postgres(), and replace_variables().
{ free(ptr); }
char* ecpg_realloc | ( | void * | ptr, | |
long | size, | |||
int | lineno | |||
) |
Definition at line 33 of file memory.c.
References ECPG_OUT_OF_MEMORY, ecpg_raise(), ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL, and realloc.
Referenced by ecpg_execute(), and ecpg_store_input().
{ char *new = (char *) realloc(ptr, size); if (!new) { ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); return NULL; } return (new); }
char* ecpg_strdup | ( | const char * | string, | |
int | lineno | |||
) |
Definition at line 47 of file memory.c.
References ECPG_OUT_OF_MEMORY, ecpg_raise(), ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, and NULL.
Referenced by AddStmtToCache(), ecpg_auto_prepare(), ecpg_store_input(), ECPGconnect(), ECPGdo(), ECPGget_desc(), and prepare_common().
{ char *new; if (string == NULL) return NULL; new = strdup(string); if (!new) { ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); return NULL; } return (new); }
void ECPGfree_auto_mem | ( | void | ) |
Definition at line 118 of file memory.c.
References ecpg_free(), get_auto_allocs, auto_mem::next, NULL, auto_mem::pointer, and set_auto_allocs.
Referenced by ecpg_raise(), ecpg_raise_backend(), ECPGset_var(), and main().
{ struct auto_mem *am = get_auto_allocs(); /* free all memory we have allocated for the user */ if (am) { do { struct auto_mem *act = am; am = am->next; ecpg_free(act->pointer); ecpg_free(act); } while (am); set_auto_allocs(NULL); } }
struct auto_mem* auto_allocs = NULL [static] |