From 0b9466fce2cf4f8c32b3a9170ca272829aa11e66 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 4 Dec 2019 19:36:06 -0300 Subject: Offer pnstrdup to frontend code We already had it on the backend. Frontend can also use it now. Discussion: https://postgr.es/m/20191204144021.GA17976@alvherre.pgsql --- src/interfaces/ecpg/compatlib/informix.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'src/interfaces/ecpg/compatlib/informix.c') diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index a7bbeb9223f..b2a19a1dd3a 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -175,25 +175,6 @@ deccopy(decimal *src, decimal *target) memcpy(target, src, sizeof(decimal)); } -static char * -ecpg_strndup(const char *str, size_t len) -{ - size_t real_len = strlen(str); - int use_len = (int) ((real_len > len) ? len : real_len); - - char *new = malloc(use_len + 1); - - if (new) - { - memcpy(new, str, use_len); - new[use_len] = '\0'; - } - else - errno = ENOMEM; - - return new; -} - int deccvasc(const char *cp, int len, decimal *np) { @@ -205,7 +186,7 @@ deccvasc(const char *cp, int len, decimal *np) if (risnull(CSTRINGTYPE, cp)) return 0; - str = ecpg_strndup(cp, len); /* decimal_in always converts the complete + str = pnstrdup(cp, len); /* decimal_in always converts the complete * string */ if (!str) ret = ECPG_INFORMIX_NUM_UNDERFLOW; -- cgit v1.2.3