Skip to content

Commit 6710e83

Browse files
committed
Remove useless pstrdups in untransformRelOptions
The two strings are already a single palloc'd chunk, not freed; there's no reason to allocate separate copies that have the same lifetime. This code is only called in short-lived memory contexts (except in some cases in TopTransactionContext, which is still short-lived enough not to really matter), and typically only for short arrays, so the memory or computation saved is likely negligible. However, let's fix it to avoid leaving a bad example of code to copy. This is the only place I could find where we're doing this with makeDefElem(). Reported-by: Junwang Zhao <zhjwpku@gmail.com> Discussion: https://postgr.es/m/20220909142050.3vv2hjekppk265dd@alvherre.pgsql
1 parent fcf7b3a commit 6710e83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/access/common/reloptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,9 @@ untransformRelOptions(Datum options)
13571357
if (p)
13581358
{
13591359
*p++ = '\0';
1360-
val = (Node *) makeString(pstrdup(p));
1360+
val = (Node *) makeString(p);
13611361
}
1362-
result = lappend(result, makeDefElem(pstrdup(s), val, -1));
1362+
result = lappend(result, makeDefElem(s, val, -1));
13631363
}
13641364

13651365
return result;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy