From b82f3288a37831f34bc7563eac316ba6879fd529 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 26 Oct 2021 20:19:58 +0200 Subject: [PATCH] string: Remove malloc attribute from para_realloc(). Quoting from the corresponding section of the gcc-10 manual: This tells the compiler that a function is 'malloc'-like, i.e., that the pointer P returned by the function cannot alias any other pointer valid when the function returns, and moreover no pointers to valid objects occur in any storage addressed by P. Using this attribute can improve optimization. Compiler predicts that a function with the attribute returns non-null in most cases. Functions like 'malloc' and 'calloc' have this property because they return a pointer to uninitialized or zeroed-out storage. However, functions like 'realloc' do not have this property, as they can return a pointer to storage containing pointers. Found by code inspection, the unpached code never caused problems. Also, the function definition in string.c does not contain the attribute. --- string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/string.h b/string.h index 10251ae7..10379a0e 100644 --- a/string.h +++ b/string.h @@ -67,7 +67,7 @@ int for_each_line(unsigned flags, char *buf, size_t size, } \ ) -__must_check __malloc void *para_realloc(void *p, size_t size); +__must_check void *para_realloc(void *p, size_t size); __must_check __malloc void *para_malloc(size_t size); __must_check __malloc void *para_calloc(size_t size); __must_check __malloc char *para_strdup(const char *s); -- 2.39.5