blob: a35ef89a0a04af82240763839e1400a6944f1969 [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
Jeff Thompsonf418fe02013-06-27 17:28:55 -07004 */
5
6/*
7 * Based on HAVE_MEMCPY and HAVE_MEMSET in config.h, use the library version or a local implementation of memcpy and memset.
8 */
9
10#ifndef NDN_MEMORY_H
11#define NDN_MEMORY_H
12
Jeff Thompson6cb56f92013-07-01 15:38:09 -070013#include "../../../config.h"
Jeff Thompsonf418fe02013-06-27 17:28:55 -070014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Jeff Thompsond4a1e162013-07-11 12:41:31 -070019#if HAVE_MEMCMP
20#include <memory.h>
21/**
22 * Use the library version of memcmp.
23 */
24static inline int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len) { memcpy(buf1, buf2, len); }
25#else
26/**
27 * Use a local implementation of memcmp instead of the library version.
28 */
29int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len);
30#endif
31
Jeff Thompsonf418fe02013-06-27 17:28:55 -070032#if HAVE_MEMCPY
33#include <memory.h>
34/**
35 * Use the library version of memcpy.
36 */
37static inline void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) { memcpy(dest, src, len); }
38#else
39/**
40 * Use a local implementation of memcpy instead of the library version.
41 */
42void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len);
43#endif
44
45#if HAVE_MEMSET
46#include <memory.h>
47/**
48 * Use the library version of memset.
49 */
50static inline void ndn_memset(unsigned char *dest, int val, unsigned int len) { memset(dest, val, len); }
51#else
52/**
53 * Use a local implementation of memset instead of the library version.
54 */
55void ndn_memset(unsigned char *dest, int val, unsigned int len);
56#endif
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
63