From a66c906bb060bfbe93cb94af1b2b910de8adf3c8 Mon Sep 17 00:00:00 2001 From: BG Date: Wed, 20 Jul 2016 21:11:41 +0300 Subject: [PATCH] Add wrapset - template-wrapper for memset --- emb/pastilda/app/app.cpp | 3 ++- emb/pastilda/app/wrapset.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 emb/pastilda/app/wrapset.h diff --git a/emb/pastilda/app/app.cpp b/emb/pastilda/app/app.cpp index 8ea95f3..38786ce 100644 --- a/emb/pastilda/app/app.cpp +++ b/emb/pastilda/app/app.cpp @@ -21,6 +21,7 @@ #include "app.h" #include "stdio.h" +#include "wrapset.h" using namespace Application; App *app_pointer; @@ -50,7 +51,7 @@ void App::redirect(uint8_t *data, uint8_t len) void App::control_interception() { - memset(app_pointer->key, 0, 8); + ZeroIt(app_pointer->key); app_pointer->key[2] = KEY_W; app_pointer->key[3] = KEY_O; app_pointer->key[4] = KEY_N; diff --git a/emb/pastilda/app/wrapset.h b/emb/pastilda/app/wrapset.h new file mode 100644 index 0000000..94fa537 --- /dev/null +++ b/emb/pastilda/app/wrapset.h @@ -0,0 +1,7 @@ +#ifndef __WRAPSET__ +#define __WRAPSET__ +template void ZeroIt(T& value) +{ + memset(&value,0,sizeof(value)); +} +#endif \ No newline at end of file