blob: 12ee1317eda06ec598ad5d20025c75086ba4d97a [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#include "ndn_memory.h"
7
Jeff Thompsond4a1e162013-07-11 12:41:31 -07008#if !HAVE_MEMCMP
9int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len)
10{
11 unsigned int i;
12
13 for (i = 0; i < len; i++) {
14 if (buf1[i] > buf2[i])
15 return 1;
16 else if (buf1[i] < buf2[i])
17 return -1;
18 }
19
20 return 0;
21}
22#else
23int ndn_memcmp_stub_to_avoid_empty_file_warning = 0;
24#endif
25
Jeff Thompsonf418fe02013-06-27 17:28:55 -070026#if !HAVE_MEMCPY
27void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len)
28{
29 unsigned int i;
30
31 for (i = 0; i < len; i++)
32 dest[i] = src[i];
33}
Jeff Thompson2275e602013-06-28 22:24:47 -070034#else
35int ndn_memcpy_stub_to_avoid_empty_file_warning = 0;
Jeff Thompsonf418fe02013-06-27 17:28:55 -070036#endif
37
38#if !HAVE_MEMSET
39void ndn_memset(unsigned char *dest, int val, unsigned int len)
40{
41 unsigned int i;
42
43 for (i = 0; i < len; i++)
44 dest[i] = (unsigned char)val;
45}
Jeff Thompson2275e602013-06-28 22:24:47 -070046#else
47int ndn_memset_stub_to_avoid_empty_file_warning = 0;
Jeff Thompsond4a1e162013-07-11 12:41:31 -070048#endif