From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Ansley, Michael" <Michael(dot)Ansley(at)intec(dot)co(dot)za> |
Cc: | "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Re: [HACKERS] pg_dump, and strings |
Date: | 1999-10-30 23:32:52 |
Message-ID: | 18986.941326372@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"Ansley, Michael" <Michael(dot)Ansley(at)intec(dot)co(dot)za> writes:
> In pg_dump there is a file called common.c. This file has some string
> handling routines in it that return a pointer to a fixed-length, static
> string (char *). I need to remove the fixed-length bit (besides the fact
> fact that this is horrendously un-threadsafe). So, what is the best
> mechanism to use on replacement? There seem to be two fairly standard
> methods to use, a) make the calling function allocate the memory it
> requires, and pass that in to the called function, or b) the called function
> allocates memory using a documented call (say, malloc), and hands
> responsibility for freeing the memory to the calling function. Given the
> non-fixed-length constraint, the second option would appear better, but does
> any body out there have any other ideas?
The first approach requires that the caller know in advance how much
result space the callee will need; unless the return type is fixed-size
that's usually a bad design.
Another possibility is to do something like the backend's palloc()
stuff, wherein responsibility for eventually cleaning up the garbage
is handed to a third party. But that's probably overkill for pg_dump.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 1999-10-30 23:35:58 | Re: [HACKERS] missing mugshots |
Previous Message | Tom Lane | 1999-10-30 22:59:44 | Performance glitch in GetCurrentAbsoluteTime() |