Python C Module - Malloc fails in specific version of Python
问题 I'm writing a Python module to perform IO on a O_DIRECT context. One of the limitations of O_DIRECT is you must read into a buffer aligned on a 4096 byte boundary for 2.4 and 2.5 kernels, and 2.6 and up will accept any multiple of 512. The obvious memory allocation candidate for this is posix_memalign(void **memptr, size_t alignment, size_t size) In my code, I allocate an area like so: char *buffer = NULL; int mem_ret = posix_memalign((void**)&buffer, alignment, size); if (!buffer) { PyErr