xref: /dflybsd-src/contrib/grep/lib/xalloc-die.c (revision 95b7b45377d922df3f9cbf9a1f160c77aa3555fa)
1*95b7b453SJohn Marino /* Report a memory allocation failure and exit.
2*95b7b453SJohn Marino 
3*95b7b453SJohn Marino    Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2009, 2010
4*95b7b453SJohn Marino    Free Software Foundation, Inc.
5*95b7b453SJohn Marino 
6*95b7b453SJohn Marino    This program is free software: you can redistribute it and/or modify
7*95b7b453SJohn Marino    it under the terms of the GNU General Public License as published by
8*95b7b453SJohn Marino    the Free Software Foundation; either version 3 of the License, or
9*95b7b453SJohn Marino    (at your option) any later version.
10*95b7b453SJohn Marino 
11*95b7b453SJohn Marino    This program is distributed in the hope that it will be useful,
12*95b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*95b7b453SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*95b7b453SJohn Marino    GNU General Public License for more details.
15*95b7b453SJohn Marino 
16*95b7b453SJohn Marino    You should have received a copy of the GNU General Public License
17*95b7b453SJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18*95b7b453SJohn Marino 
19*95b7b453SJohn Marino #include <config.h>
20*95b7b453SJohn Marino 
21*95b7b453SJohn Marino #include "xalloc.h"
22*95b7b453SJohn Marino 
23*95b7b453SJohn Marino #include <stdlib.h>
24*95b7b453SJohn Marino 
25*95b7b453SJohn Marino #include "error.h"
26*95b7b453SJohn Marino #include "exitfail.h"
27*95b7b453SJohn Marino 
28*95b7b453SJohn Marino #include "gettext.h"
29*95b7b453SJohn Marino #define _(msgid) gettext (msgid)
30*95b7b453SJohn Marino 
31*95b7b453SJohn Marino void
32*95b7b453SJohn Marino xalloc_die (void)
33*95b7b453SJohn Marino {
34*95b7b453SJohn Marino   error (exit_failure, 0, "%s", _("memory exhausted"));
35*95b7b453SJohn Marino 
36*95b7b453SJohn Marino   /* The `noreturn' cannot be given to error, since it may return if
37*95b7b453SJohn Marino      its first argument is 0.  To help compilers understand the
38*95b7b453SJohn Marino      xalloc_die does not return, call abort.  Also, the abort is a
39*95b7b453SJohn Marino      safety feature if exit_failure is 0 (which shouldn't happen).  */
40*95b7b453SJohn Marino   abort ();
41*95b7b453SJohn Marino }
42