From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Morgan Kita <mkita(at)verseon(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Major problem with custom data type |
Date: | 2005-04-02 06:29:11 |
Message-ID: | 20050402062911.GA10327@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Fri, Apr 01, 2005 at 11:21:24PM -0500, Tom Lane wrote:
>
> There's nothing obviously wrong in what you posted ... other than the
> very poor style of misspelling "VARHDRSZ" as "4", not using VARDATA and
> VARATT_SIZEP macros, and generally doing your best to ignore every one
> of the portability conventions that are built into the Postgres
> sources.
Do you recommend always using the macros, even if the data is a
structure? For example, I've done things like the following:
typedef struct foo
{
int32 size;
int32 numitems;
float8 item[1];
} foo;
and then
foo *p;
size = sizeof(*p) + (numitems - 1) * sizeof(p->item);
p = palloc(size);
p->size = size;
p->numitems = numitems;
for (i = 0; i < numitems; ++i)
p->item[i] = /* some value */;
I see similar code in arrayfuncs.c. Is this style safe, or would
you suggest changing the code to use the macros?
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-04-02 06:43:10 | Re: Major problem with custom data type |
Previous Message | Tom Lane | 2005-04-02 04:21:24 | Re: Major problem with custom data type |