| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | /* xalloc.h -- malloc with out-of-memory checking |
| 3 | |
| 4 | Copyright (C) 1990-2000, 2003-2004, 2006-2012 Free Software Foundation, Inc. |
| 5 | |
| 6 | This program is free software: you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 3 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef XALLOC_H_ |
| 20 | # define XALLOC_H_ |
| 21 | |
| 22 | # ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | # endif |
| 25 | |
| 26 | void *xmalloc (const size_t s) |
| 27 | _attribute_malloc_ _attribute_alloc_size_ ((1)); |
| 28 | void *xmemdup (void const *p, const size_t s) |
| 29 | _attribute_malloc_ _attribute_alloc_size_ ((2)); |
| 30 | char *xstrdup (char const *str) |
| 31 | _attribute_malloc_; |
| 32 | char *xsubstrdup (char const *start, const size_t s) |
| 33 | _attribute_malloc_; |
| 34 | void *xnmalloc (const size_t n, const size_t s) |
| 35 | _attribute_malloc_ _attribute_alloc_size_ ((1, 2)); |
| 36 | void *xrealloc (void *p, const size_t s) |
| 37 | _attribute_malloc_ _attribute_alloc_size_ ((2)); |
| 38 | |
| 39 | #ifdef __cplusplus |
| 40 | } |
| 41 | #endif |
| 42 | |
| 43 | #endif /* XALLOC_H_ */ |