File: malloc.c

package info (click to toggle)
awe 0.4.2c-3
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 1,576 kB
  • ctags: 3,918
  • sloc: ansic: 19,225; tcl: 2,105; sh: 369; makefile: 104
file content (24 lines) | stat: -rw-r--r-- 320 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

void *safe_malloc(int size)
{
	void *p;
	p = (void*)calloc(size, 1);
	if (p == NULL) {
		fprintf(stderr, "can't malloc buffer for size %d!!\n", size);
		exit(1);
	}
	return p;
}

void safe_free(void *buf)
{
	if (buf)
		free(buf);
}