On Tue, Aug 26, 2014 at 12:25 PM, David Woodhouse <dwmw2 at infradead.org> wrote: > On Mon, 2014-08-25 at 10:40 +0200, Nikos Mavrogiannopoulos wrote: >> +/* This function should be used to allocate memory for openconect */ >> +char *openconnect_strdup(const char *s); > Eww! I suppose this is an aspect of the Windows "DLL Hell", where > different DLLs can actually be using *different* C runtime libraries, > and memory allocated in one libc *must* be freed in the same libc? > I really don't like requiring that users on *sane* systems must use > openconnect_strdup() to allocate memory. And it's quite horrid even for > the Windows side where you arguably deserve the pain you get for > developing on that platform. I'll modify the text to say that this is applicable in windows. > Isn't it conventional to pass in alloc/free functions to the library? > That seems hard though, since *all* of our strdup/asprintf/etc would > need to be hacked to use them. > How about letting the caller provide just a free() function, and we can > either keep track of which strings come from outside and free them with > the appropriate function, or convert them to internal strings by using > strdup() + free_func() if it's too hard to keep track. Isn't the current openconnect_strdup() process simpler? Only on function is exported, and it is straightforward to use. regards, Nikos