OSDN Git Service

Fix allocation of low-alignment memory
authorNicolas Capens <capn@google.com>
Thu, 14 Mar 2019 18:52:59 +0000 (14:52 -0400)
committerNicolas Capens <nicolascapens@google.com>
Thu, 14 Mar 2019 20:23:48 +0000 (20:23 +0000)
commitbecb44f1177a8e7231cda1559b784ef5377ad9c2
tree48d7b6e6f97cd550448e922c8362d613fbf34509
parenta2749f39f47dd61b6f18972f6471993c6b5c1928
Fix allocation of low-alignment memory

posix_memalign() returns EINVAL if the alignment argument is not a
multiple of sizeof(void*). Use regular malloc() for those cases.
malloc() is specified to allocate memory which is "suitably aligned for
any built-in type".

Bug b/128618202

Change-Id: Ibee07be89f2a5bd6be770c35710b20b0c752dfd1
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27228
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
src/Common/Memory.cpp
src/Reactor/ExecutableMemory.cpp
src/System/Memory.cpp