De: sur-behoffski <[email protected]>
Enviado: domingo, 26 de abril de 2020 00:39
Para: IUP discussion list.
Assunto: [Iup-users] Patch to simplify IM's (r757) src/process/im_analyze.cpp
G'day,
I've been steering clear of IM, partially as much of its code is from
third-party libraries, and partially because activity on the project SVN
tree was so low.
However, I notice that there were three SVN commits in the past few
day, so, I've started looking at non-third-party code as a candidate for
change.
I'm trying to reduce GCC's warnings, without altering the code
semantics in any way.
I've found that there are a number of cases of the warning
"-Wmisleading-indent", relating to the code:
if (cm20) free(cm20); if (cm02) free(cm02); if (cm11) free(cm11);
Looking at the documentation for free(3), it states that NULL (0) is
explicitly allowed as a parameter, and the call will be a no-op. The
GNU documentation states that this has been formalised at least in C89,
as well as all C and C++ standards since: 30 years ago.
I know that during the '80s, there were some C compilers that generated
code which crashed if free(NULL) was called, but I believe that in the
modern era, this concern is no longer valid. Similarly, I believe that
the compiler toolchains handle the NULL case without heavily penalising
the caller (perhaps by defining "free" as a macro internally, and doing
the NULL check in the macro expansion before attempting a call).
Therefore, the above code could be rewritten as:
free(cm20); free(cm02); free(cm11);
+1
I've tried without success, say what on that list. Which is a waste to test
against NULL before calling free.
regards,
Ranier Vilela
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users