Re: Question about coding of free space map - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Question about coding of free space map
Date
Msg-id 54006E94.3050007@vmware.com
Whole thread Raw
In response to Question about coding of free space map  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: Question about coding of free space map
List pgsql-hackers
On 08/26/2014 05:13 AM, Tatsuo Ishii wrote:
> While looking into backend/storage/freespace/freespace.c, I noticed
> that struct FSMAddress is passed to functions by value, rather than
> reference. I thought our code practice is defining pointer to a struct
> data and using the pointer for parameter passing etc.
>
> typedef struct RelationData *Relation;
>
> IMO freespace.c is better to follow the practice.

There isn't really any strict coding rule on that. We pass RelFileNode's 
by value in many functions, for example.

IMHO it's clearer to pass small structs like this by value. For example, 
it irritates me that we tend to pass ItemPointers by reference, when 
it's a small struct that represents a single value. I think of it as an 
atomic value, like an integer, so it feels wrong to pass it by reference.

- Heikki




pgsql-hackers by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: LIMIT for UPDATE and DELETE
Next
From: Ali Akbar
Date:
Subject: Re: [REVIEW] Re: Fix xpath() to return namespace definitions