在C中使用MySQL时,可以使用MySQL API释放内存,如下所示:
MYSQL* connection = NULL;
connection = mysql_init(NULL);
// Stuff...
mysql_close(connection);但是Splint不知道mysql_close实际上是在释放内存,所以我得到了以下错误:
Fresh storage connection not released before return
A memory leak has been detected. Storage allocated locally is
not released before the last reference to it is lost. (Use
-mustfreefresh to inhibit warning)我如何告诉夹板,mysql_close正在释放内存?mysql.h文件的特殊注释?
编辑:好的,可能是releases *p注释,如果可以在头文件中使用的话。会尽力的。
编辑2:将/*@releases *sock@*/添加到mysql.h,但现在获得此错误:
Releases clauses includes *sock of non-dynamically allocated
type MYSQL
A declaration uses an invalid annotation. (Use -annotationerror to inhibit
warning)这是mysql_close的信号
void STDCALL mysql_close(/*@notnull@*/ MYSQL *sock) /*@releases *sock@*/;发布于 2014-08-07 17:21:32
我相信正确的注释是:
void STDCALL mysql_close(/*@special@*/ /*@notnull@*/ MYSQL *sock)
/*@releases sock@*/;您遗漏的关键是/*@special@*/注释,这是“激活”所谓的状态子句所必需的。从夹板的文档,7.4国家条款
/*@special@*/注释用于标记使用状态子句描述的参数、全局变量或返回值。
https://stackoverflow.com/questions/25186861
复制相似问题