diff options
author | Michael Meskes <meskes@postgresql.org> | 2007-10-03 11:11:12 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2007-10-03 11:11:12 +0000 |
commit | 7793c6ecca0560de152ec8dc0dea22d22c5d59af (patch) | |
tree | 6eeeda7309747308a3a1dd4e586e0fc95c1ef624 /src/interfaces/ecpg/compatlib/informix.c | |
parent | c4a6c2f87166c70cd773c5521d4ff104ddec9e61 (diff) | |
download | postgresql-7793c6ecca0560de152ec8dc0dea22d22c5d59af.tar.gz postgresql-7793c6ecca0560de152ec8dc0dea22d22c5d59af.zip |
Cleaned up ecpglib and renamed functions that do not need to be exported.
Created export list for ecpglib.
Diffstat (limited to 'src/interfaces/ecpg/compatlib/informix.c')
-rw-r--r-- | src/interfaces/ecpg/compatlib/informix.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index 032ccaf89a3..b1f78aebafe 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.49 2007/08/14 10:01:52 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.50 2007/10/03 11:11:11 meskes Exp $ */ #include <stdlib.h> #include <string.h> @@ -7,14 +7,15 @@ #include <ctype.h> #include <limits.h> +#define POSTGRES_ECPG_INTERNAL #include <ecpgtype.h> #include <ecpg_informix.h> #include <pgtypes_error.h> #include <pgtypes_date.h> #include <pgtypes_numeric.h> #include <sqltypes.h> - -char *ECPGalloc(long, int); +#include <sqlca.h> +#include <ecpgerrno.h> static int deccall2(decimal *arg1, decimal *arg2, int (*ptr) (numeric *, numeric *)) @@ -667,7 +668,7 @@ static struct * initialize the struct, which holds the different forms * of the long value */ -static void +static int initValue(long lng_val) { int i, @@ -701,7 +702,8 @@ initValue(long lng_val) value.remaining = value.digits; /* convert the long to string */ - value.val_string = (char *) malloc(value.digits + 1); + if ((value.val_string = (char *) malloc(value.digits + 1)) == NULL) + return -1; dig = value.val; for (i = value.digits, j = 0; i > 0; i--, j++) { @@ -710,6 +712,7 @@ initValue(long lng_val) l /= 10; } value.val_string[value.digits] = '\0'; + return 0; } /* return the position oft the right-most dot in some string */ @@ -755,7 +758,11 @@ rfmtlong(long lng_val, char *fmt, char *outbuf) temp = (char *) malloc(fmt_len + 1); /* put all info about the long in a struct */ - initValue(lng_val); + if (!temp || initValue(lng_val) == -1) + { + errno = ENOMEM; + return -1; + } /* '<' is the only format, where we have to align left */ if (strchr(fmt, (int) '<')) @@ -991,11 +998,25 @@ ECPG_informix_set_var(int number, void *pointer, int lineno) } /* a new one has to be added */ - ptr = (struct var_list *) ECPGalloc(sizeof(struct var_list), lineno); - ptr->number = number; - ptr->pointer = pointer; - ptr->next = ivlist; - ivlist = ptr; + ptr = (struct var_list *) calloc(1L, sizeof(struct var_list)); + if (!ptr) + { + struct sqlca_t *sqlca = ECPGget_sqlca(); + + sqlca->sqlcode = ECPG_OUT_OF_MEMORY; + strncpy(sqlca->sqlstate, "YE001", sizeof("YE001")); + snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "Out of memory in line %d.", lineno); + sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc); + /* free all memory we have allocated for the user */ + ECPGfree_auto_mem(); + } + else + { + ptr->number = number; + ptr->pointer = pointer; + ptr->next = ivlist; + ivlist = ptr; + } } void * |