blob: 0cf45d33aea439f387db8af986e3303f9b1c77b5 [file] [log] [blame]
The Android Open Source Project10e23ee2009-03-03 19:30:30 -08001/**
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