/* lp_util.h
 * Neil Moore <neil@cs.uky.edu>
 * 20 Jul 1999
 *
 * Part of liblp.  See COPYRIGHT for copyright information.
 */
#ifndef _UTIL_H_INCLUDED
#define _UTIL_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

/* Allocate memory, dying on error */
void *lp_malloc(size_t size);
void *lp_calloc(size_t nmemb, size_t size);
void *lp_realloc(void *ptr, size_t size);

/* Read up to end-of-line */
int lp_finishline(FILE *f);
/* Read an nonnegative integer */
int lp_getnum(FILE *f);
/* Read an nonnegative integer on a line of its own */
int lp_getnumline(FILE *f);

/* Copy an array of integers */
int *lp_copy_array(int *array, int nelts);
/* Compare two arrays of integers */
int lp_eq_array(int *a, int *b, int len);


/* Wrapper around assert.  If LP_DEBUG is defined and NDEBUG is not defined,
 * lp_assert() tests its argument, and aborts if it is not true; otherwise,
 * it does nothing---in particular, it does not then evaluate its argument.
 */
#ifdef LP_DEBUG
#define lp_assert(x) assert(x)
#else
#define lp_assert(x) ((void) 0)
#endif

#endif /* _LP_UTIL_H_INCLUDED */
