MCPcopy Create free account
hub / github.com/apache/cloudberry / replaceStringInfoString

Function replaceStringInfoString

src/common/stringinfo.c:364–379  ·  view source on GitHub ↗

* Replace all occurrences of a string in a StringInfo with a different string. */

Source from the content-addressed store, hash-verified

362 * Replace all occurrences of a string in a StringInfo with a different string.
363 */
364void
365replaceStringInfoString(StringInfo str, char *replace, char *replacement)
366{
367 char *ptr;
368
369 while ((ptr = strstr(str->data, replace)) != NULL)
370 {
371 char *dup = pstrdup(str->data);
372
373 resetStringInfo(str);
374 appendBinaryStringInfo(str, dup, ptr - str->data);
375 appendStringInfoString(str, replacement);
376 appendStringInfoString(str, dup + (ptr - str->data) + strlen(replace));
377 pfree(dup);
378 }
379}

Callers 2

MangleCopyFileNameFunction · 0.85

Calls 5

resetStringInfoFunction · 0.85
appendBinaryStringInfoFunction · 0.85
appendStringInfoStringFunction · 0.85
pstrdupFunction · 0.70
pfreeFunction · 0.70

Tested by

no test coverage detected