lokinet/llarp/util/mem.cpp

42 lines
729 B
C++
Raw Normal View History

#define NO_JEMALLOC
#include <util/mem.h>
#include <cstdlib>
2018-01-08 13:49:05 +00:00
#include <absl/base/attributes.h>
2018-05-18 12:39:17 +00:00
namespace llarp
{
void
Zero(void *ptr, size_t sz)
2018-05-18 12:39:17 +00:00
{
uint8_t *p = (uint8_t *)ptr;
2018-05-18 12:39:17 +00:00
while(sz--)
{
*p = 0;
++p;
}
}
2018-07-09 03:34:29 +00:00
} // namespace llarp
2018-05-16 18:13:18 +00:00
void
llarp_mem_slab(ABSL_ATTRIBUTE_UNUSED struct llarp_alloc *mem,
ABSL_ATTRIBUTE_UNUSED uint32_t *buf,
ABSL_ATTRIBUTE_UNUSED size_t sz)
{
// not implemented
abort();
}
2018-05-20 13:43:42 +00:00
bool
llarp_eq(const void *a, const void *b, size_t sz)
{
bool result = true;
const uint8_t *a_ptr = (const uint8_t *)a;
const uint8_t *b_ptr = (const uint8_t *)b;
while(sz--)
2018-05-20 13:43:42 +00:00
{
result &= a_ptr[sz] == b_ptr[sz];
2018-05-20 13:43:42 +00:00
}
return result;
}