marcus905 / libnfc

Automatically exported from code.google.com/p/libnfc
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Offer a library free string function #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
nfc_device_get_information_about and str_nfc_target both allocate strings for 
the caller.

The implicit assumption is the allocator is standardized and calling free is ok.

However, to be safe libnfc should offer its own function to free the strings 
(and perhaps other objects). This gives the cleaner option of swapping 
allocators for example.

In my case, in writing a wrapper into .NET, I cannot free the strings cleanly 
as invoking "free" may not align to the right C runtime version.

Original issue reported on code.google.com by alex.l...@gmail.com on 11 Feb 2013 at 3:13

GoogleCodeExporter commented 9 years ago
Ok, fine.

Do you have API suggests (one function, multiple functions, which name, etc.) ?

Original comment by romu...@libnfc.org on 14 Feb 2013 at 7:17

GoogleCodeExporter commented 9 years ago
void libnfc_free(void *) is probably all we need, which of course for now just 
calls free().

Looking at the sqlite model, they have void sqlite3_free(void*) as well.

At some point, someone might ask for allocator configuration, but that can be 
safely added later with not too much work.

Original comment by alex.l...@gmail.com on 14 Feb 2013 at 11:43

GoogleCodeExporter commented 9 years ago
Fixed in rf8601886fdfa.

Thank you!

Original comment by romu...@libnfc.org on 16 Feb 2013 at 1:26