| Perhaps it would be worthwhile to define a realloc attribute. That
| would have the opportunity to optimize code like this:
|
| c1 = *p1;
| p2 = realloc(p1, n);
| c2 = *p2;
|
| because we know that c1 == c2.
That makes sense.
Do we have some kind of data whether such codes are widespread?
Adding such an attribute is worthwhile for the purpose of explicitly
differentiating realloc from malloc. :-) Were someone to write
code that let GCC notice such patterns, I'd be left wondering if
more compile time was spent on the analysis that was saved in the
aggregate world of computing.....
"Joseph S. Myers" <jsm@polyomino.org.uk> writes:
| The @code{malloc} attribute .....
| +Standard functions with this property include @code{malloc},
| +@code{calloc} and @code{realloc}.
That is a clear improvement!
I think we'd better off not listing realloc for reasons exposed in
this thread.
Much better off.