eina/mp/one_big: fix alignment issues.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Mon, 20 Jan 2014 23:27:58 +0000 (21:27 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Mon, 20 Jan 2014 23:44:42 +0000 (21:44 -0200)
commitdbc4669d6818d733d1d512f766ad8cf4c799dbba
tree4a74dba888ad04a3785b0ae0e9d28d108597ffa7
parentedc548fac5497c1bd8d7c35c2942f6686baa64c4
eina/mp/one_big: fix alignment issues.

When over-allocating (past "pool->max" items) a memory slice will be
allocated to the new item as a linked list using Eina_Inlist.

The original code was placing the Eina_Inlist structure (3 pointers)
at the beginning of the allocated memory. However the item must have
proper alignment based on "pool->item_size", otherwise a structure may
end with unaligned members. Take for example MIPS 32 bits, it uses 4
bytes pointers with 8 bytes double. A structure containing a double
could have it unaligned as 12 % 8 = 4 (12 is the size of Eina_Inlist,
that contains 3 pointers), and MIPS doesn't allow unaligned access.

Albin Tonnerre (Lutin) spotted this in his Debian MIPS test machine,
it was breaking at eet_data_get_double() that was storing an unaligned
double. This was being called from within edje test suite.

The current code will place the list node after the requested
"pool->item_size", of course guaranteeing the pointer inside the node
is aligned (otherwise a "char" or "short" would break its alignment).
src/modules/eina/mp/one_big/eina_one_big.c