Re: Persistence problem

From: "I(dot) B(dot)" <i(dot)bre(at)live(dot)com>
To: <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <kleptog(at)svana(dot)org>, <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Persistence problem
Date: 2010-05-15 10:37:01
Message-ID: SNT128-W20BAE5D398E4C346BCDC1991FE0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks a lot for the patience and help. It worked.

Ivan

> To: i(dot)bre(at)live(dot)com
> CC: kleptog(at)svana(dot)org; dalroi(at)solfertje(dot)student(dot)utwente(dot)nl; pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Persistence problem
> Date: Fri, 14 May 2010 18:34:14 -0400
> From: tgl(at)sss(dot)pgh(dot)pa(dot)us
>
> "I. B." <i(dot)bre(at)live(dot)com> writes:
> > OK, here is the part of the code.
>
> Well, as suspected, you're doing this
>
> > typedef struct {
> > void *units;
> > } mapping_t;
>
> and this
>
> > units = (uPoint *) realloc(units, result->noOfUnits * sizeof(uPoint)); // EXPLAINED AT THE END OF THE POST
>
> which means that the array isn't contiguous with the mPoint struct.
> You can certainly do that and then rearrange things to make it so
> afterwards, but you're not doing so now. Personally though I'd avoid
> having two different representations. You'd be better off with
>
> typedef struct {
> int4 length;
> int noOfUnits;
> uPoint units[1]; /* actually, a variable length array */
> } mPoint;
>
> and then allocating or reallocating the result struct with a size
> calculation like this:
>
> offsetof(mPoint, units) + noOfUnits * sizeof(uPoint)
>
> BTW, realloc (as opposed to repalloc) doesn't seem like a tremendously
> good idea here. You are leaking that memory for the life of the session.
>
> regards, tom lane

_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rob Wultsch 2010-05-15 13:37:12 Re: List traffic
Previous Message Marc G. Fournier 2010-05-15 07:51:53 Re: [HACKERS] List traffic