1 /* 2 * Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 3 * 2012, 2013 Free Software Foundation, Inc. 4 * 5 * This file is part of GNU libmatheval 6 * 7 * GNU libmatheval is free software: you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation, either version 3 of the 10 * License, or (at your option) any later version. 11 * 12 * GNU libmatheval is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU libmatheval. If not, see 19 * <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef XMALLOC_H 23 #define XMALLOC_H 1 24 25 /* Macro definitions to simplify corresponding function calls. */ 26 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 27 #define XREALLOC(type, ptr, num) ((type *) xrealloc ((ptr), (num) * sizeof(type))) 28 #define XCALLOC(type, num) ((type *) xcalloc ((num), sizeof(type))) 29 #define XFREE(stale) free (stale); 30 31 /* Replacement for malloc() function with error checking. */ 32 void *xmalloc(size_t size); 33 34 /* Same as above from realloc(). */ 35 void *xrealloc(void *ptr, size_t size); 36 37 /* Same as above for calloc(). */ 38 void *xcalloc(size_t num, size_t size); 39 40 #endif 41