The first utility function is compare_ints(). This function is not
used by <@xref{\NODE\, , test.c.>,97} but it is included there because it is used by the
test modules for all the individual tree structures.
/* Utility functions. */
<@xref{\NODE\, , Comparison function for int.>s,3}
See also @refalso{136
This code is included in @refalso{97
It is prototyped in <@xref{\NODE\, , test.h.>,99}:
The fail() function prints a provided error message to stderr,
formatting it as with printf(), and terminates the program
unsuccessfully:
/* Prints message on stderr, which is formatted as for printf(),
and terminates the program unsuccessfully. */
staticvoid fail (constchar *message, ...) {va_listargs;
fprintf (stderr, "%s:", pgm_name);
va_start (args, message);
vfprintf (stderr, message, args);
va_end (args);
putchar ('\n');
exit (EXIT_FAILURE);
}
Finally, the xmalloc() function is a malloc() wrapper that aborts
the program if allocation fails:
/* Allocates and returns a pointer to size bytes of memory.
Aborts if allocation fails. */
staticvoid * xmalloc (size_tsize) {void *block = malloc (size);
if (block == NULL && size != 0)
fail ("outofmemory");
returnblock;
}
Please take a moment to fill out
this visitor survey You can help support this site by
visiting the advertisers that sponsor it! (only once each, though)