summaryrefslogtreecommitdiff
path: root/src/backend/lib/stringinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/lib/stringinfo.c')
-rw-r--r--src/backend/lib/stringinfo.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c
index 18f19e1f62..d326e5e612 100644
--- a/src/backend/lib/stringinfo.c
+++ b/src/backend/lib/stringinfo.c
@@ -29,8 +29,6 @@ makeStringInfo(void)
StringInfo res;
res = (StringInfo) palloc(sizeof(StringInfoData));
- if (res == NULL)
- elog(ERROR, "makeStringInfo: Out of memory");
initStringInfo(res);
@@ -49,9 +47,6 @@ initStringInfo(StringInfo str)
int size = 256; /* initial default buffer size */
str->data = (char *) palloc(size);
- if (str->data == NULL)
- elog(ERROR,
- "initStringInfo: Out of memory (%d bytes requested)", size);
str->maxlen = size;
str->len = 0;
str->data[0] = '\0';
@@ -62,6 +57,11 @@ initStringInfo(StringInfo str)
*
* Internal routine: make sure there is enough space for 'needed' more bytes
* ('needed' does not include the terminating null).
+ *
+ * NB: because we use repalloc() to enlarge the buffer, the string buffer
+ * will remain allocated in the same memory context that was current when
+ * initStringInfo was called, even if another context is now current.
+ * This is the desired and indeed critical behavior!
*/
static void
enlargeStringInfo(StringInfo str, int needed)
@@ -83,9 +83,6 @@ enlargeStringInfo(StringInfo str, int needed)
newlen = 2 * newlen;
str->data = (char *) repalloc(str->data, newlen);
- if (str->data == NULL)
- elog(ERROR,
- "enlargeStringInfo: Out of memory (%d bytes requested)", newlen);
str->maxlen = newlen;
}