source: anuga_work/development/anugavis/src/xfunctions.c @ 5267

Last change on this file since 5267 was 5267, checked in by jack, 16 years ago

AnugaVis?: compile the data into openGL display lists.

File size: 743 bytes
Line 
1#ifdef HAVE_CONFIG_H
2#  include "config.h"
3#endif
4
5#ifdef HAVE_STDLIB_H
6#  include <stdlib.h>
7#endif
8#ifdef HAVE_STRING_H
9#  include <string.h>
10#endif
11#include "error.h"
12#include "xfunctions.h"
13
14void *xmalloc(size_t size, const char *message){
15  void *mem;
16  if((mem = malloc(size)) == NULL)
17    AnugaVis_SetError("%s: Failed to malloc %d bytes", message, size);
18  return mem;
19}
20
21#ifndef HAVE_STRDUP
22char *strdup(const char *s){
23  char *str;
24  if((str = malloc(strlen(s) + 1)) != NULL)
25    strcpy(str, s);
26  return str;
27}
28#endif
29
30char *xstrdup(const char *s, const char *message){
31  char *str;
32  if((str = strdup(s)) == NULL)
33    AnugaVis_SetError("%s: Failed to strdup \"%s\"", message, s);
34  return str;
35}
Note: See TracBrowser for help on using the repository browser.