blob: 8051864a65a925975e98b2a30673583e834c7d50 [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson47eecfc2013-07-07 22:56:46 -07004 * See COPYING for copyright and distribution information.
Jeff Thompsonf418fe02013-06-27 17:28:55 -07005 */
6
7#include "ndn_memory.h"
8
Jeff Thompsonb7523002013-10-09 10:25:00 -07009#if !NDN_CPP_HAVE_MEMCMP
Jeff Thompson97223af2013-09-24 17:01:27 -070010int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len)
Jeff Thompsond4a1e162013-07-11 12:41:31 -070011{
Jeff Thompson97223af2013-09-24 17:01:27 -070012 size_t i;
Jeff Thompsond4a1e162013-07-11 12:41:31 -070013
14 for (i = 0; i < len; i++) {
15 if (buf1[i] > buf2[i])
16 return 1;
17 else if (buf1[i] < buf2[i])
18 return -1;
19 }
20
21 return 0;
22}
23#else
24int ndn_memcmp_stub_to_avoid_empty_file_warning = 0;
25#endif
26
Jeff Thompsonb7523002013-10-09 10:25:00 -070027#if !NDN_CPP_HAVE_MEMCPY
Jeff Thompson97223af2013-09-24 17:01:27 -070028void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len)
Jeff Thompsonf418fe02013-06-27 17:28:55 -070029{
Jeff Thompson97223af2013-09-24 17:01:27 -070030 size_t i;
Jeff Thompsonf418fe02013-06-27 17:28:55 -070031
32 for (i = 0; i < len; i++)
33 dest[i] = src[i];
34}
Jeff Thompson2275e602013-06-28 22:24:47 -070035#else
36int ndn_memcpy_stub_to_avoid_empty_file_warning = 0;
Jeff Thompsonf418fe02013-06-27 17:28:55 -070037#endif
38
Jeff Thompsonb7523002013-10-09 10:25:00 -070039#if !NDN_CPP_HAVE_MEMSET
Jeff Thompson97223af2013-09-24 17:01:27 -070040void ndn_memset(uint8_t *dest, int val, size_t len)
Jeff Thompsonf418fe02013-06-27 17:28:55 -070041{
Jeff Thompson97223af2013-09-24 17:01:27 -070042 size_t i;
Jeff Thompsonf418fe02013-06-27 17:28:55 -070043
44 for (i = 0; i < len; i++)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070045 dest[i] = (uint8_t)val;
Jeff Thompsonf418fe02013-06-27 17:28:55 -070046}
Jeff Thompson2275e602013-06-28 22:24:47 -070047#else
48int ndn_memset_stub_to_avoid_empty_file_warning = 0;
Jeff Thompsond4a1e162013-07-11 12:41:31 -070049#endif