libpayload: add xmemalign()
Similarly to xzalloc() and xmalloc() provide an xmemalign() function to do the approriate assertions on allocation failure. BUG=None BRANCH=None TEST=Built and booted using xmemalign(). Change-Id: I59579d9ee973af3bb34037b7df5b1024b60e348d Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 3001822656024dbfc34d6b849a0245274b8c0f46 Original-Change-Id: Ie307d4c9c1882bba25745afe38455f2682303e37 Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/242455 Original-Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/8728 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
e5be1dc336
commit
c88cca1c38
|
@ -174,6 +174,20 @@ static inline void *xzalloc_work(size_t size, const char *file,
|
|||
return ret;
|
||||
}
|
||||
#define xzalloc(size) xzalloc_work((size), __FILE__, __FUNCTION__, __LINE__)
|
||||
|
||||
static inline void *xmemalign_work(size_t align, size_t size, const char *file,
|
||||
const char *func, int line)
|
||||
{
|
||||
void *ret = memalign(align, size);
|
||||
if (!ret && size) {
|
||||
die_work(file, func, line,
|
||||
"Failed to memalign %zu bytes with %zu alignment.\n",
|
||||
size, align);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#define xmemalign(align, size) \
|
||||
xmemalign_work((align), (size), __FILE__, __func__, __LINE__)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue