* lib/alignalloc.h: Include <cheri.h>.
(alignalloc): When size is 0, return a pointer whose bounds are of
size 0, not 1.
+2023-11-11 Bruno Haible <bruno@clisp.org>
+
+ alignalloc: Take advantage of CHERI bounds-checking.
+ * lib/alignalloc.h: Include <cheri.h>.
+ (alignalloc): When size is 0, return a pointer whose bounds are of
+ size 0, not 1.
+
2023-11-11 Bruno Haible <bruno@clisp.org>
rawmemchr tests: Add test case for last commit.
#include <errno.h>
#include <stdlib.h>
#include "idx.h"
+#if defined __CHERI__
+# include <cheri.h>
+#endif
_GL_INLINE_HEADER_BEGIN
#ifndef ALIGNALLOC_INLINE
if (alignment < sizeof (void *))
alignment = sizeof (void *);
errno = posix_memalign (&ptr, alignment, size | !size);
+# if defined __CHERI__
+ if (ptr != NULL)
+ ptr = cheri_bounds_set (ptr, size);
+# endif
return ptr;
# endif
}