Hi Justin,
On Wed, 2010-09-29 at 11:48 -0700, Justin Malcolm wrote:
From the 'easy hacks' page it seemed that getting rid of warnings and
flags by tools like cppcheck was a goal.
Sure ! of course :-)
Attached is a small patch that does nothing except eliminate one
cppcheck warning. It is contributed under the LGPL3+.
What is the warning ? :-)
As I said, it does nothing different and, depending on the compiler,
it could even be less efficient. It does however make cppcheck happy.
Is this kind of thing useful?
Certainly; clearly it'd be more re-assuring if it was compiled & ran
afterwards.
xrealloc(void *ptr, size_t size)
{
- ptr = realloc(ptr, size);
+ void *newptr = realloc(ptr, size);
- if ( !ptr )
+ if (!newptr)
+ ptr = newptr;
+ else
err_quit("out of memory");
return ptr;
So for size > 0 - realloc will return a non-NULL (perhaps different)
pointer. So - if (!newptr) [ ie. if (newptr == NULL) ] will never
succeed - surely ?
HTH,
Michael.
--
michael.meeks@novell.com <><, Pseudo Engineer, itinerant idiot
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.