Electroneum
Loading...
Searching...
No Matches
slow_memmem.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include "gtest/gtest.h"
#include <malloc.h>
Include dependency graph for slow_memmem.cpp:

Go to the source code of this file.

Namespaces

namespace  cryptonote
 Holds cryptonote related classes and helpers.

Functions

size_t cryptonote::slow_memmem (const void *start_buff, size_t buflen, const void *pat, size_t patlen)
 TEST (slowmem, Success)

Function Documentation

◆ TEST()

TEST ( slowmem ,
Success  )

Definition at line 109 of file slow_memmem.cpp.

110{
111 size_t n;
112 for (n=0;n<sizeof(T)/sizeof(T[0]);++n) {
113#ifdef VERBOSE
114 printf("%3zu: ",n);
115 fflush(stdout);
116#endif
117 void *buf=malloc(T[n].buflen);
118 memcpy(buf,T[n].buf,T[n].buflen);
119 void *pat=malloc(T[n].patlen);
120 memcpy(pat,T[n].pat,T[n].patlen);
121 size_t res=slow_memmem(buf,T[n].buflen,pat,T[n].patlen);
122 free(pat);
123 free(buf);
124 ASSERT_EQ(res,T[n].res);
125#ifdef VERBOSE
126 if (res!=T[n].res) printf("failed (got %zu, expected %zu)",res,T[n].res); else printf("ok");
127 printf("\n");
128#endif
129 }
130}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
void * memcpy(void *a, const void *b, size_t c)
const char * res
size_t slow_memmem(const void *start_buff, size_t buflen, const void *pat, size_t patlen)
size_t patlen
const char * pat
size_t buflen
const char * buf
#define T(x)
Here is the call graph for this function:

Variable Documentation

◆ buf

const char* buf

Definition at line 74 of file slow_memmem.cpp.

◆ buflen

size_t buflen

Definition at line 73 of file slow_memmem.cpp.

◆ pat

const char* pat

Definition at line 76 of file slow_memmem.cpp.

◆ patlen

size_t patlen

Definition at line 75 of file slow_memmem.cpp.

◆ res

size_t res

Definition at line 77 of file slow_memmem.cpp.