* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.17 2001/11/15 23:31:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.17.2.1 2002/05/05 17:38:28 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
{
ds->value = palloc(ds->alloc = 512);
ds->used = 0;
+ ds->value[0] = '\0';
}
plpgsql_dstring_append(PLpgSQL_dstring * ds, char *str)
{
int len = strlen(str);
+ int needed = ds->used + len + 1;
- if (ds->used + len + 1 > ds->alloc)
+ if (needed > ds->alloc)
{
- ds->alloc *= 2;
+ /* might have to double more than once, if len is large */
+ do {
+ ds->alloc *= 2;
+ } while (needed > ds->alloc);
ds->value = repalloc(ds->value, ds->alloc);
}