File: utils.cc

package info (click to toggle)
massivethreads 1.02-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,924 kB
  • sloc: ansic: 27,814; sh: 4,559; cpp: 3,334; javascript: 1,799; makefile: 1,745; python: 523; asm: 373; perl: 118; lisp: 9
file content (19 lines) | stat: -rw-r--r-- 306 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* utils.cc */

#include <cstdlib>
#include <cstdio>

void * xmalloc(size_t size)
{
  void *p = malloc(size);
  if (p == NULL) {
    perror("memory allocation failed");
    exit(1);
  }
  return p;
}

double xrandom(double xl, double xh)
{
  return (xl + (xh - xl) * ((double) random()) / 2147483647.0);
}