File: misc.c

package info (click to toggle)
fdutils 5.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,004 kB
  • ctags: 621
  • sloc: ansic: 6,098; sh: 2,236; makefile: 279; sed: 4
file content (31 lines) | stat: -rw-r--r-- 429 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include "fdutils.h"


void *safe_calloc(size_t nmemb, size_t size)
{
  void *ptr;

  ptr = calloc(nmemb, size);
  if(!ptr) {
    fprintf(stderr,"Out of memory error\n");
    exit(1);
  }
  return ptr;
}


void *safe_malloc(size_t size)
{
  void *ptr;

  ptr = malloc(size);

  if(!ptr) {
    fprintf(stderr,"Out of memory error\n");
    exit(1);
  }
  return ptr;
}