From: Andre Noll Date: Tue, 26 Oct 2021 18:19:58 +0000 (+0200) Subject: string: Remove malloc attribute from para_realloc(). X-Git-Tag: v0.6.4~3 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=b82f3288a37831f34bc7563eac316ba6879fd529 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. --- 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);