On Fri, 11 Aug 2006, Kelly Burkhart wrote: > On 8/10/06, Scott <drmemory@xxxxxxxxxxx> wrote: > > With the caveat that I haven't done any serious programming in C for > > many years: As I recall, I always used a protocol halfway between > > these, as: > > > > char *func(size_t bufsiz) > > { > > char *retval = malloc (bufsiz); > > if (retval == NULL) return (NULL); > > /* whatever */ > > return (retval); > > } > > This code is to live in a shared library and you wish for it to be > portable then you may want to keep in mind the difficulties on some > platforms of allocating memory in one shared library and freeing in > another. If this concern is relevant to you, the above must be > paired with void funcCleanup(char*). obviously, if i chose to do it this way, i'd first check if a malloc() had already been done, so i don't keep malloc()ing unnecessarily (keeping a static pointer, naturally). that would seem to be functionally equivalent to just declaring a static array of characters within that routine, anyway. rday - : send the line "unsubscribe linux-c-programming" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html