[issue18835] Add PyMem_AlignedAlloc()
STINNER Victor
report at bugs.python.org
Thu Nov 2 07:40:59 EDT 2017
STINNER Victor <victor.stinner at gmail.com> added the comment:
About the API itself, I'm not sure that PyMem_AlignedAlloc(alignment, size) is flexible enough. If we want to get *data* aligned in a Python object, we would have to pass an offset to the data, since Python objects have headers of variable size (depending on the type).
Windows has such API:
void * _aligned_offset_malloc(
size_t size,
size_t alignment,
size_t offset
);
This function is based on malloc, so likely adds padding bytes for you depending on size, alignment and offset.
https://msdn.microsoft.com/fr-fr/library/ec852tkw.aspx
See bpo-27987: "obmalloc's 8-byte alignment causes undefined behavior".
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue18835>
_______________________________________
More information about the Python-bugs-list
mailing list