You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#ifndef LLARP_MEM_HPP
|
|
|
|
#define LLARP_MEM_HPP
|
|
|
|
#include <llarp/buffer.h>
|
|
|
|
#include <llarp/mem.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
void
|
|
|
|
Zero(void *ptr, size_t sz);
|
|
|
|
|
|
|
|
template < typename T >
|
|
|
|
void
|
|
|
|
dumphex(const uint8_t *t)
|
|
|
|
{
|
|
|
|
size_t idx = 0;
|
|
|
|
while(idx < sizeof(T))
|
|
|
|
{
|
|
|
|
printf("%.2x ", t[idx++]);
|
|
|
|
if(idx % 8 == 0)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template < typename T, size_t align = 8 >
|
|
|
|
void
|
|
|
|
DumpBuffer(const T &buff)
|
|
|
|
{
|
|
|
|
size_t idx = 0;
|
|
|
|
printf("buffer of size %ld\n", buff.sz);
|
|
|
|
while(idx < buff.sz)
|
|
|
|
{
|
|
|
|
if(buff.base + idx == buff.cur)
|
|
|
|
{
|
|
|
|
printf("%c[1;31m", 27);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("%c[0m", 27);
|
|
|
|
}
|
|
|
|
if(buff.base[idx])
|
|
|
|
{
|
|
|
|
printf("%c", buff.base[idx]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("X");
|
|
|
|
}
|
|
|
|
++idx;
|
|
|
|
if(idx % align == 0)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|