1/**
2 * @file op_libiberty.c
3 * Wrapper for libiberty - always use this instead of
4 * libiberty.h
5 *
6 * @remark Copyright 2002 OProfile authors
7 * @remark Read the file COPYING
8 *
9 * @author John Levon
10 * @author Philippe Elie
11 */
12
13#include <string.h>
14
15#include "op_libiberty.h"
16
17#ifndef HAVE_XCALLOC
18/* some system have a valid libiberty without xcalloc */
19void * xcalloc(size_t n_elem, size_t sz)
20{
21	void * ptr = xmalloc(n_elem * sz);
22
23	memset(ptr, '\0', n_elem * sz);
24
25	return ptr;
26}
27#endif
28
29#ifndef HAVE_XMEMDUP
30void * xmemdup (void const * input, size_t copy_size, size_t alloc_size)
31{
32	void * output = xcalloc(1, alloc_size);
33
34	memcpy(output, input, copy_size);
35
36	return output;
37}
38#endif
39