mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
tests: use xmalloc to allocate implementation array
The benchmark and tests must fail in case of allocation failure in the implementation array. Also annotate the x* allocators in support.h so that the compiler has more information about them. Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
#include <programs/xmalloc.h>
|
||||||
|
|
||||||
/* We are compiled under _ISOMAC, so libc-symbols.h does not do this
|
/* We are compiled under _ISOMAC, so libc-symbols.h does not do this
|
||||||
for us. */
|
for us. */
|
||||||
@@ -200,7 +201,7 @@ static impl_t *impl_array;
|
|||||||
skip = impl; \
|
skip = impl; \
|
||||||
else \
|
else \
|
||||||
impl_count++; \
|
impl_count++; \
|
||||||
a = impl_array = malloc ((impl_count + func_count) * \
|
a = impl_array = xmalloc ((impl_count + func_count) * \
|
||||||
sizeof (impl_t)); \
|
sizeof (impl_t)); \
|
||||||
for (impl = __start_impls; impl < __stop_impls; ++impl) \
|
for (impl = __start_impls; impl < __stop_impls; ++impl) \
|
||||||
if (impl != skip) \
|
if (impl != skip) \
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
#include <support/support.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -146,7 +147,7 @@ static impl_t *impl_array;
|
|||||||
skip = impl; \
|
skip = impl; \
|
||||||
else \
|
else \
|
||||||
impl_count++; \
|
impl_count++; \
|
||||||
a = impl_array = malloc ((impl_count + func_count) * \
|
a = impl_array = xmalloc ((impl_count + func_count) * \
|
||||||
sizeof (impl_t)); \
|
sizeof (impl_t)); \
|
||||||
for (impl = __start_impls; impl < __stop_impls; ++impl) \
|
for (impl = __start_impls; impl < __stop_impls; ++impl) \
|
||||||
if (impl != skip) \
|
if (impl != skip) \
|
||||||
|
@@ -87,14 +87,24 @@ int support_descriptor_supports_holes (int fd);
|
|||||||
/* Error-checking wrapper functions which terminate the process on
|
/* Error-checking wrapper functions which terminate the process on
|
||||||
error. */
|
error. */
|
||||||
|
|
||||||
void *xmalloc (size_t) __attribute__ ((malloc));
|
extern void *xmalloc (size_t n)
|
||||||
void *xcalloc (size_t n, size_t s) __attribute__ ((malloc));
|
__attribute_malloc__ __attribute_alloc_size__ ((1)) __attr_dealloc_free
|
||||||
void *xrealloc (void *p, size_t n);
|
__returns_nonnull;
|
||||||
void *xposix_memalign (size_t alignment, size_t n);
|
extern void *xcalloc (size_t n, size_t s)
|
||||||
|
__attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __attr_dealloc_free
|
||||||
|
__returns_nonnull;
|
||||||
|
extern void *xrealloc (void *o, size_t n)
|
||||||
|
__attribute_malloc__ __attribute_alloc_size__ ((2)) __attr_dealloc_free;
|
||||||
|
extern char *xstrdup (const char *) __attribute_malloc__ __attr_dealloc_free
|
||||||
|
__returns_nonnull;
|
||||||
|
void *xposix_memalign (size_t alignment, size_t n)
|
||||||
|
__attribute_malloc__ __attribute_alloc_size__ ((2)) __attr_dealloc_free
|
||||||
|
__returns_nonnull;
|
||||||
char *xasprintf (const char *format, ...)
|
char *xasprintf (const char *format, ...)
|
||||||
__attribute__ ((format (printf, 1, 2), malloc));
|
__attribute__ ((format (printf, 1, 2), malloc)) __attr_dealloc_free
|
||||||
char *xstrdup (const char *);
|
__returns_nonnull;
|
||||||
char *xstrndup (const char *, size_t);
|
char *xstrdup (const char *) __attr_dealloc_free __returns_nonnull;
|
||||||
|
char *xstrndup (const char *, size_t) __attr_dealloc_free __returns_nonnull;
|
||||||
char *xsetlocale (int category, const char *locale);
|
char *xsetlocale (int category, const char *locale);
|
||||||
locale_t xnewlocale (int category_mask, const char *locale, locale_t base);
|
locale_t xnewlocale (int category_mask, const char *locale, locale_t base);
|
||||||
char *xuselocale (locale_t newloc);
|
char *xuselocale (locale_t newloc);
|
||||||
|
Reference in New Issue
Block a user