| From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | confusing typedefs in jsonfuncs.c |
| Date: | 2013-07-19 01:20:16 |
| Message-ID: | 1374196816.15766.8.camel@vanquo.pezone.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
The new jsonfuncs.c has some confusing typedef scheme. For example, it
has a bunch of definitions like this:
typedef struct getState
{
...
} getState, *GetState;
So GetState is a pointer to getState. I have never seen that kind of
convention before.
This then leads to code like
GetState state;
state = palloc0(sizeof(getState));
which has useless mental overhead.
But the fact that GetState is really a pointer isn't hidden at all,
because state is then derefenced with -> or cast from or to void*. So
whatever abstraction might have been intended isn't there at all. And
all of this is an intra-file interface anyway.
And to make this even more confusing, other types such as ColumnIOData
and JsonLexContext are not pointers but structs directly.
I think a more typical PostgreSQL code convention is to use capitalized
camelcase for structs, and use explicit pointers for pointers. I have
attached a patch that cleans this up, in my opinion.
| Attachment | Content-Type | Size |
|---|---|---|
| jsonfuncs.patch | text/x-patch | 24.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2013-07-19 01:34:44 | Re: confusing typedefs in jsonfuncs.c |
| Previous Message | David Fetter | 2013-07-19 00:56:01 | Foreign Tables as Partitions |