Summary: Record that it is not supported: https://github.com/facebook/infer/issues/8 Reviewed By: mbouaziz, dulmarod Differential Revision: D8442762 fbshipit-source-id: fa271cbmaster
parent
dd8b0bcd51
commit
25627fd4d9
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void cleanup_char(char** x) { free(*x); }
|
||||||
|
|
||||||
|
void cleanup_int(int** x) { free(*x); }
|
||||||
|
|
||||||
|
// related to https://github.com/facebook/infer/issues/8
|
||||||
|
void FP_cleanup_malloc_good() {
|
||||||
|
__attribute__((cleanup(cleanup_int))) int* x;
|
||||||
|
x = malloc(sizeof(int));
|
||||||
|
if (x != NULL) {
|
||||||
|
*x = 10;
|
||||||
|
}
|
||||||
|
/* s goes out of scope. Cleanup function called - no leak */
|
||||||
|
}
|
||||||
|
|
||||||
|
// related to https://github.com/facebook/infer/issues/8
|
||||||
|
void FP_cleanup_string_good() {
|
||||||
|
__attribute__((cleanup(cleanup_char))) char* s;
|
||||||
|
s = strdup("demo string");
|
||||||
|
/* s goes out of scope. Cleanup function called - no leak */
|
||||||
|
}
|
Loading…
Reference in new issue