3 Error checking memory allocator
9 Copyright (C) 2000-2006 Kern Sibbald
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 version 2 as amended with additional clauses defined in the
14 file LICENSE in the main source directory.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 the file LICENSE for additional details.
39 extern void *sm_malloc();
41 /* SM_ALLOC -- Allocate buffer and signal on error */
43 void *sm_alloc(char *fname, int lineno, unsigned int nbytes)
47 if ((buf = sm_malloc(fname, lineno, nbytes)) != NULL) {
50 V fprintf(stderr, "\nBoom!!! Memory capacity exceeded.\n");
51 V fprintf(stderr, " Requested %u bytes at line %d of %s.\n",
52 nbytes, lineno, fname);
58 /* ALLOC -- Allocate buffer and signal on error */
60 void *alloc(unsigned int nbytes)
64 if ((buf = malloc(nbytes)) != NULL) {
67 V fprintf(stderr, "\nBoom!!! Memory capacity exceeded.\n");
68 V fprintf(stderr, " Requested %u bytes.\n", nbytes);