1 /*
2 * mpatrol
3 * A library for controlling and tracing dynamic memory allocations.
4 * Copyright (C) 1997-2002 Graeme S. Roy <graeme.roy@analog.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307, USA.
20 */
21
22
23 /*
24 * Allocation failure handler. This is used to set the allocation failure
25 * handler that is called by the versions of MP_MALLOC() and related functions
26 * that are defined in mpalloc.h instead of returning NULL.
27 */
28
29
30 #include "config.h"
31 #include "mpalloc.h"
32
33
34 #if MP_IDENT_SUPPORT
35 #ident "$Id: mpsetfail.c,v 1.5 2002/01/08 20:13:59 graeme Exp $"
36 #else /* MP_IDENT_SUPPORT */
37 static MP_CONST MP_VOLATILE char *mpsetfail_id = "$Id: mpsetfail.c,v 1.5 2002/01/08 20:13:59 graeme Exp $";
38 #endif /* MP_IDENT_SUPPORT */
39
40
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif /* __cplusplus */
45
46
47 extern __mp_failhandler __mp_failure;
48
49
50 /* Set the allocation failure handler and return the previous setting.
51 */
52
53 MP_API
54 __mp_failhandler
__mp_setfailhandler(__mp_failhandler h)55 __mp_setfailhandler(__mp_failhandler h)
56 {
57 __mp_failhandler p;
58
59 p = __mp_failure;
60 __mp_failure = h;
61 return p;
62 }
63
64
65 #ifdef __cplusplus
66 }
67 #endif /* __cplusplus */
68