File: alloc.c

package info (click to toggle)
rhyme 0.9-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 3,704 kB
  • ctags: 225
  • sloc: ansic: 2,394; makefile: 99; python: 31
file content (17 lines) | stat: -rw-r--r-- 413 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "alloc.h"

/*This is a wrapper around malloc() that kills rhyme unhappily
  if the requested space cannot be allocated.*/
void *testalloc(size_t size) {
  void *toreturn;

  toreturn = (void *)malloc(size);

  if (toreturn == NULL) {
    fprintf(stderr, "Out of memory trying to allocate %d bytes\n", size);
    fprintf(stderr, "Program terminated\n");
    exit(2);
  } else {
    return toreturn;
  }
}