s3/lib/ctdbd_conn: assert hdr following read/recv
[Samba.git] / lib / util / talloc_keep_secret.h
blob44a26aef5421c5acb23c51b1055080f9e456c1b4
1 /*
2 * Copyright (c) 2019 Andreas Schneider <asn@samba.org>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef _TALLOC_KEEP_SECRET_H
19 #define _TALLOC_KEEP_SECRET_H
21 #ifdef DOXYGEN
22 /**
23 * @brief Keep the memory secret when freeing.
25 * This can be used to define memory as secret. For example memory which holds
26 * passwords or other secrets like session keys. The memory will be zeroed
27 * before is being freed.
29 * If you duplicate memory, e.g. using talloc_strdup() or talloc_asprintf() you
30 * need to call talloc_keep_secret() on the newly allocated memory too!
32 * @param[in] ptr The talloc chunk to mark as secure.
34 * @warning Do not use this in combination with talloc_realloc().
36 void talloc_keep_secret(const void *ptr);
37 #else
38 #define talloc_keep_secret(ptr) _talloc_keep_secret(ptr, #ptr);
39 void _talloc_keep_secret(void *ptr, const char *name);
40 #endif
42 #endif /* _TALLOC_KEEP_SECRET_H */