lundi 30 mars 2015

Stack based allocation not recommended?



The libmemcached documentation has this note:



You may wish to avoid using memcached_create(3) or memcached_clone(3) with a stack based allocation. The most common issues related to ABI safety involve heap allocated structures.



How do I have to understand it? Stands in this case ABI for Application Binary Interface? I would like to provide the pointer to the struct for memcached_clone() from a variable in the local function scope. Is it safe?


Example - is this code OK?



foo()
{
memcached_st clone_memc;

memcached_clone(&clone_memc, master_memc);

// some memcache function calls (get/set)
...

memcached_free(&clone_memc);
}



Aucun commentaire:

Enregistrer un commentaire