/****************************************************************** 
 *
 * syswrappers.c
 *
 *     Implementation of system call wrapper functions.
 *
 *
 * $Author: mstoufer $
 * $Source: /home/g2/src/projects/NetLogger/src/nlv/syswrappers.c,v $
 * $RCSfile: syswrappers.c,v $
 * $Revision: 1.1.1.1 $
 * $Locker:  $
 * $Date: 2000/12/05 19:52:33 $
 *
 ****************************************************************** 
 */
static char rcsid[] = "$Id: syswrappers.c,v 1.1.1.1 2000/12/05 19:52:33 mstoufer Exp $";

#include <stdlib.h>
#include "syswrappers.h"

extern Nlv_err eobj;
extern Nlv_err eobj2;

/*========= FUNCTIONS ================================================*/

/*
 *----------------------------------------------------------------------
 *
 * Nlv_Malloc -- Wrapper for malloc.
 *
 * Calls: malloc
 *
 * Algorithm: Exit code=1 if error.
 *
 *----------------------------------------------------------------------
 */

void * Nlv_Malloc( size_t numbytes )
{
  void * r = malloc( numbytes );

  if ( NULL == r ) {
    char errmsg[256];
    sprintf(errmsg,"Could not allocate %d bytes", (int)numbytes);
    Nlv_errPrintString( eobj, "Nlv_Malloc", errmsg );
    exit(1);
  }

  return r;
}

/* This version uses 'eobj2' for error reporting */
void * Nlv_Malloc2( size_t numbytes )
{
  void * r = malloc( numbytes );

  if ( NULL == r ) {
    char errmsg[256];
    sprintf(errmsg,"Could not allocate %d bytes", (int)numbytes);
    Nlv_errPrintString( eobj2, "Nlv_Malloc", errmsg );
    exit(1);
  }

  return r;
}


