the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
+#include "hconfig.h"
#include "bi-parser.h"
-extern char *malloc ();
-extern char *realloc ();
-
-
/* Current read buffer and point */
static char *buffer = NULL;
static char *inpoint = NULL;
xmalloc (nbytes)
int nbytes;
{
- char *tmp = malloc (nbytes);
+ char *tmp = (char *) malloc (nbytes);
if (!tmp)
{
fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
- exit (1);
+ exit (FATAL_EXIT_CODE);
}
return tmp;
char *block;
int nbytes;
{
- char *tmp = realloc (block, nbytes);
+ char *tmp = (block
+ ? (char *) realloc (block, nbytes)
+ : (char *) malloc (nbytes));
if (!tmp)
{
fprintf (stderr, "can't reallocate %d bytes (out of virtual memory)\n", nbytes);
- exit (1);
+ exit (FATAL_EXIT_CODE);
}
return tmp;
int previous_point_index = point - buffer;
buffer_size = (!buffer_size ? 32 : buffer_size * 2);
- if (buffer)
+ if (!buffer)
buffer = xmalloc (buffer_size);
else
buffer = xrealloc (buffer, buffer_size);