From: Krzysztof Jackiewicz Date: Mon, 13 Jun 2016 12:49:38 +0000 (+0200) Subject: YACA: Add helper types/functions for pointer management X-Git-Tag: security-manager_5.5_testing~94 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d826424f6049df218b4dd2ec283e8c800c4cd07a;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git YACA: Add helper types/functions for pointer management Change-Id: Iecdd6e8bfc36477a7c20c081a7788073fff66c60 --- diff --git a/src/yaca/yaca-test-common.cpp b/src/yaca/yaca-test-common.cpp index eee4c27d..edfb971f 100644 --- a/src/yaca/yaca-test-common.cpp +++ b/src/yaca/yaca-test-common.cpp @@ -49,3 +49,18 @@ const char *yaca_error(int error) { return yaca_debug_translate_error(static_cast(error)); } + +KeyPtr wrap_ptr(yaca_key_h key) +{ + return KeyPtr(key, yaca_key_destroy); +} + +CtxPtr wrap_ptr(yaca_context_h ctx) +{ + return CtxPtr(ctx, yaca_context_destroy); +} + +BufPtr wrap_ptr(char* buffer) +{ + return BufPtr(buffer, yaca_free); +} diff --git a/src/yaca/yaca-test-common.h b/src/yaca/yaca-test-common.h index 9b6663de..f05db57f 100644 --- a/src/yaca/yaca-test-common.h +++ b/src/yaca/yaca-test-common.h @@ -26,9 +26,11 @@ #include #include #include +#include #include #include +#include #include #include @@ -94,3 +96,11 @@ do { \ #define YACA_SUCCESS(func) YACA_RESULT(YACA_ERROR_NONE, func); #define YACA_INVALID_PARAM(func) YACA_RESULT(YACA_ERROR_INVALID_PARAMETER, func); + +typedef std::unique_ptr KeyPtr; +typedef std::unique_ptr CtxPtr; +typedef std::unique_ptr BufPtr; + +KeyPtr wrap_ptr(yaca_key_h key); +CtxPtr wrap_ptr(yaca_context_h ctx); +BufPtr wrap_ptr(char* buffer);