[PATCH 4/6] added openconnect_strdup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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.

-- 
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5745 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openconnect-devel/attachments/20140826/1acdec2d/attachment.bin>


[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux