1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/mem.cpp

40 lines
701 B
C++
Raw Normal View History

#define NO_JEMALLOC
2018-01-25 17:24:33 +01:00
#include <llarp/mem.h>
#include <cstdlib>
2018-01-08 14:49:05 +01:00
2018-05-18 14:39:17 +02:00
namespace llarp
{
void
Zero(void *ptr, size_t sz)
2018-05-18 14:39:17 +02:00
{
uint8_t *p = (uint8_t *)ptr;
2018-05-18 14:39:17 +02:00
while(sz--)
{
*p = 0;
++p;
}
}
2018-07-09 05:34:29 +02:00
} // namespace llarp
2018-05-16 20:13:18 +02:00
void
llarp_mem_slab(__attribute__((unused)) struct llarp_alloc *mem,
__attribute__((unused)) uint32_t *buf,
__attribute__((unused)) size_t sz)
{
// not implemented
abort();
}
2018-05-20 15:43:42 +02: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 15:43:42 +02:00
{
result &= a_ptr[sz] == b_ptr[sz];
2018-05-20 15:43:42 +02:00
}
return result;
}