Dave Trollope <[EMAIL PROTECTED]> writes:
> #define safemalloc(length) \
>    (malloc((length) <= 0 ? 1 : (length)) ? : (char
> *)alloc_failed("malloc",(length)))
> 
> The main advantage of this is that only one function call for each
> malloc is required (malloc itself) instead of two (safemalloc+malloc).
> ?: is supposed to be more efficient than if () but I'm not sure thats
> really true. If I could only disassemble the code.... Suggestions?

This is for gcc, every compiler I've seen has similar options:

     -S    Stop after the stage of compilation proper; do not as-
          semble.   The output is an assembler code file for each
          non-assembler input file specified.

          By default, GCC makes the assembler  file  name  for  a
          source  file  by replacing the suffix `.c', `.i', etc.,
          with `.s'.  Use -o to select another name.

Be sure to compile optimized, I don't think ?: would have any
advantage over if in properly optimized code.

Maybe you want to quantify some of the memory impacts.

Please, don't send us HTML.

-- 
Dan Espen                           E-mail: [EMAIL PROTECTED]
444 Hoes Lane  Room RRC 1C-214      Phone: (732) 699-5570
Piscataway, NJ 08854
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to