]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
string: Remove malloc attribute from para_realloc().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 26 Oct 2021 18:19:58 +0000 (20:19 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 27 Oct 2021 19:44:04 +0000 (21:44 +0200)
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

index 10251ae7c10b734bd906a644e0832e29b9e6bd9c..10379a0e83098f392e8653467b826925376eda15 100644 (file)
--- 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);