I'm currently writing Go bindings for the libfreefare.
Go provides garbage collection, Go programmers expect that objects which aren't
tied to external resources do not need explicit deinitialization. A
MifareDESFireKey is such an object. It contains a key used for initialization.
As far as I am concerned, a MifareDESFireKey does not allocate any resources
and can be free'd at any time.
Right now, MifareDESFireKeys are allocated by the libfreefare using malloc()
and free(). This makes it very hard to give control over allocation to a
garbage collector: You need two layers of wrapping which causes performance
loss and an unneccessary amount of extra garbage to be allocated. Library
support is needed to be able to control the allocation of MifareDESFireKeys.
I request to implement one of the following things:
1) Completely define struct mifare_desfire_key in freefare.h and for each
function mifare_desfire_*_key_new() provide an additional
mifare_desfire_*_key_init() with the same effect, except that you explicitly
pass a MifareDESFireKey.
2) Provide a function mifare_desfire_key_sizeof() that returns sizeof(struct
mifare_desfire_key_sizeof) and otherwise proceed as in 1).
3) For each function mifare_desfire_*_key_new() provide an additional
mifare_desfire_*_key_custom_new() with an extra parameter
void *(*alloc)(size_t size)
to pass a custom memory allocation routine. Albeit not perfect, this would
already simplify allocation control by a big deal. What is missing is the
ability to embed a MifareDESFireKey into a custom Go struct to save even more
space.
Original issue reported on code.google.com by fuz...@gmail.com on 25 Feb 2014 at 12:58
Original issue reported on code.google.com by
fuz...@gmail.com
on 25 Feb 2014 at 12:58