From 5cbed0464cee7543c8e122770b9e6d2123d74de5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 30 May 2020 17:41:44 +0200 Subject: [PATCH] opencv2.cfg: Add types, macros, functions and memory (de)allocation (#2620) * opencv2.cfg: Add types, macros, functions and memory (de)allocation * cfg/cppcheck-cfg.rng: Allow alloc/realloc functions in classes --- cfg/cppcheck-cfg.rng | 14 +++++++---- cfg/opencv2.cfg | 55 ++++++++++++++++++++++++++++++++++++++++++++ test/cfg/opencv2.cpp | 10 ++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/cfg/cppcheck-cfg.rng b/cfg/cppcheck-cfg.rng index d393a6383..9864ba111 100644 --- a/cfg/cppcheck-cfg.rng +++ b/cfg/cppcheck-cfg.rng @@ -35,7 +35,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -570,6 +570,12 @@ + + + [a-zA-Z_][a-zA-Z_0-9:]* + + + [a-zA-Z_][a-zA-Z_0-9:,]* diff --git a/cfg/opencv2.cfg b/cfg/opencv2.cfg index e71d1b007..797035c1e 100644 --- a/cfg/opencv2.cfg +++ b/cfg/opencv2.cfg @@ -5,7 +5,19 @@ + + + + + + + + + + + + @@ -22,11 +34,54 @@ + + + + cv::fastMalloc + cv::fastFree + + + + true + + + + + + + + + + + + + + + + + + + false + + + + + + + + false + + + + + 0: + + false diff --git a/test/cfg/opencv2.cpp b/test/cfg/opencv2.cpp index c6056f40b..505cd83bf 100644 --- a/test/cfg/opencv2.cpp +++ b/test/cfg/opencv2.cpp @@ -26,6 +26,9 @@ void validCode(char* argStr) cv::String cvStr("Hello"); cvStr += " World"; std::cout << cvStr; + + char * pBuf = (char *)cv::fastMalloc(20); + cv::fastFree(pBuf); } void ignoredReturnValue() @@ -33,3 +36,10 @@ void ignoredReturnValue() // cppcheck-suppress ignoredReturnValue cv::imread("42.png"); } + +void memleak() +{ + char * pBuf = (char *)cv::fastMalloc(1000); + std::cout << pBuf; + // cppcheck-suppress memleak +}