Add more detail why repalloc and pfree do not accept NULL pointers
authorPeter Eisentraut <[email protected]>
Sun, 28 Aug 2022 07:55:04 +0000 (09:55 +0200)
committerPeter Eisentraut <[email protected]>
Sun, 28 Aug 2022 07:55:04 +0000 (09:55 +0200)
Per discussion, we choose not to change this.  This just gives a
little bit more information.

Discussion: https://www.postgresql.org/message-id/flat/cf26e970-8e92-59f1-247a-aa265235075b%40enterprisedb.com

src/backend/utils/mmgr/README

index 221b4bd34337f51dc3d927c2f29f76ee5a09bf1c..777481c83d363f247a71e417e731e1c2dd240a21 100644 (file)
@@ -67,6 +67,12 @@ chunk might later be repalloc'd larger; it can also be pfree'd without
 error.  Similarly, repalloc allows realloc'ing to zero size.
 
 * pfree and repalloc do not accept a NULL pointer.  This is intentional.
+(For repalloc, this is necessary: As mentioned above, repalloc does
+not depend on the current memory context.  But then it needs to know
+which memory context to do the allocation in.  So the first allocation
+has to be done outside of repalloc.  For pfree, this behavior is
+mostly historical and partially because the extra check would impact
+performance.)
 
 
 The Current Memory Context