1*6b445a62SJohn Marino /* xfree.c -- safe version of free that ignores attempts to free NUL */ 2*6b445a62SJohn Marino 3*6b445a62SJohn Marino /* Copyright (C) 1991-2010 Free Software Foundation, Inc. 4*6b445a62SJohn Marino 5*6b445a62SJohn Marino This file is part of the GNU Readline Library (Readline), a library 6*6b445a62SJohn Marino for reading lines of text with interactive input and history editing. 7*6b445a62SJohn Marino 8*6b445a62SJohn Marino Readline is free software: you can redistribute it and/or modify 9*6b445a62SJohn Marino it under the terms of the GNU General Public License as published by 10*6b445a62SJohn Marino the Free Software Foundation, either version 3 of the License, or 11*6b445a62SJohn Marino (at your option) any later version. 12*6b445a62SJohn Marino 13*6b445a62SJohn Marino Readline is distributed in the hope that it will be useful, 14*6b445a62SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 15*6b445a62SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*6b445a62SJohn Marino GNU General Public License for more details. 17*6b445a62SJohn Marino 18*6b445a62SJohn Marino You should have received a copy of the GNU General Public License 19*6b445a62SJohn Marino along with Readline. If not, see <http://www.gnu.org/licenses/>. 20*6b445a62SJohn Marino */ 21*6b445a62SJohn Marino 22*6b445a62SJohn Marino #define READLINE_LIBRARY 23*6b445a62SJohn Marino 24*6b445a62SJohn Marino #if defined (HAVE_CONFIG_H) 25*6b445a62SJohn Marino #include <config.h> 26*6b445a62SJohn Marino #endif 27*6b445a62SJohn Marino 28*6b445a62SJohn Marino #if defined (HAVE_STDLIB_H) 29*6b445a62SJohn Marino # include <stdlib.h> 30*6b445a62SJohn Marino #else 31*6b445a62SJohn Marino # include "ansi_stdlib.h" 32*6b445a62SJohn Marino #endif /* HAVE_STDLIB_H */ 33*6b445a62SJohn Marino 34*6b445a62SJohn Marino #include <stdio.h> 35*6b445a62SJohn Marino 36*6b445a62SJohn Marino #include "xmalloc.h" 37*6b445a62SJohn Marino #include "readline.h" 38*6b445a62SJohn Marino 39*6b445a62SJohn Marino /* **************************************************************** */ 40*6b445a62SJohn Marino /* */ 41*6b445a62SJohn Marino /* Memory Deallocation. */ 42*6b445a62SJohn Marino /* */ 43*6b445a62SJohn Marino /* **************************************************************** */ 44*6b445a62SJohn Marino 45*6b445a62SJohn Marino /* Use this as the function to call when adding unwind protects so we 46*6b445a62SJohn Marino don't need to know what free() returns. */ 47*6b445a62SJohn Marino void xfree(string)48*6b445a62SJohn Marinoxfree (string) 49*6b445a62SJohn Marino PTR_T string; 50*6b445a62SJohn Marino { 51*6b445a62SJohn Marino /* Leak a bit. */ 52*6b445a62SJohn Marino if (RL_ISSTATE(RL_STATE_SIGHANDLER)) 53*6b445a62SJohn Marino return; 54*6b445a62SJohn Marino 55*6b445a62SJohn Marino if (string) 56*6b445a62SJohn Marino free (string); 57*6b445a62SJohn Marino } 58