mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Cast result of copyObject() to correct type
copyObject() is declared to return void *, which allows easily assigning the result independent of the input, but it loses all type checking. If the compiler supports typeof or something similar, cast the result to the input type. This creates a greater amount of type safety. In some cases, where the result is assigned to a generic type such as Node * or Expr *, new casts are now necessary, but in general casts are now unnecessary in the normal case and indicate that something unusual is happening. Reviewed-by: Mark Dilger <hornschnorter@gmail.com>
This commit is contained in:
@ -43,7 +43,7 @@
|
||||
|
||||
/* Copy a field that is a pointer to some kind of Node or Node tree */
|
||||
#define COPY_NODE_FIELD(fldname) \
|
||||
(newnode->fldname = copyObject(from->fldname))
|
||||
(newnode->fldname = copyObjectImpl(from->fldname))
|
||||
|
||||
/* Copy a field that is a pointer to a Bitmapset */
|
||||
#define COPY_BITMAPSET_FIELD(fldname) \
|
||||
@ -4507,7 +4507,7 @@ _copyDropSubscriptionStmt(const DropSubscriptionStmt *from)
|
||||
*/
|
||||
#define COPY_NODE_CELL(new, old) \
|
||||
(new) = (ListCell *) palloc(sizeof(ListCell)); \
|
||||
lfirst(new) = copyObject(lfirst(old));
|
||||
lfirst(new) = copyObjectImpl(lfirst(old));
|
||||
|
||||
static List *
|
||||
_copyList(const List *from)
|
||||
@ -4610,13 +4610,13 @@ _copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *from)
|
||||
|
||||
|
||||
/*
|
||||
* copyObject
|
||||
* copyObjectImpl -- implementation of copyObject(); see nodes/nodes.h
|
||||
*
|
||||
* Create a copy of a Node tree or list. This is a "deep" copy: all
|
||||
* substructure is copied too, recursively.
|
||||
*/
|
||||
void *
|
||||
copyObject(const void *from)
|
||||
copyObjectImpl(const void *from)
|
||||
{
|
||||
void *retval;
|
||||
|
||||
|
Reference in New Issue
Block a user