summaryrefslogtreecommitdiffstats
path: root/src/compat/malloc.c
blob: 0c8bb2c81a27067e0a0ed31d43876040a1bf8231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* -*- mode: c; c-file-style: "openbsd" -*- */
/* malloc replacement that can allocate 0 byte */

#undef malloc
#include <stdlib.h>
#include <sys/types.h>
#include "compat.h"

/* Allocate an N-byte block of memory from the heap.
   If N is zero, allocate a 1-byte block.  */
void *
rpl_malloc(size_t n)
{
	if (n == 0) n = 1;
	return malloc(n);
}