File: mem.c

package info (click to toggle)
aoeui 1.4-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 440 kB
  • ctags: 574
  • sloc: ansic: 6,005; makefile: 76; sh: 11
file content (20 lines) | stat: -rw-r--r-- 434 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* Copyright 2007, 2008 Peter Klausler.  See COPYING for license. */
#include "all.h"

/* Error-checking wrappers for memory management */

void *reallocate(const void *old, size_t bytes)
{
	void *new = realloc((void *) old, bytes);
	if (!new && bytes)
		die("could not allocate %lu bytes", (long) bytes);
	return new;
}

void *allocate0(size_t bytes)
{
	void *new = allocate(bytes);
	if (new)
		memset(new, 0, bytes);
	return new;
}