1 /* Copyright (C) 1989-2018 Free Software Foundation, Inc.
2 Written by James Clark (jjc@jclark.com)
4 This file is part of groff.
6 groff is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 extern "C" const char *program_name;
29 static void ewrite(const char *s)
31 write(2, s, strlen(s));
34 void *operator new(size_t size)
36 // Avoid relying on the behaviour of malloc(0).
40 char *p = (char *)malloc(unsigned(size + 8));
41 #else /* not COOKIE_BUG */
42 char *p = (char *)malloc(unsigned(size));
43 #endif /* not COOKIE_BUG */
49 ewrite("out of memory\n");
53 ((unsigned *)p)[1] = 0;
55 #else /* not COOKIE_BUG */
57 #endif /* not COOKIE_BUG */
60 void operator delete(void *p)
64 free((void *)((char *)p - 8));
68 #endif /* COOKIE_BUG */
71 void operator delete(void *p,
72 __attribute__((__unused__)) long unsigned int size)
74 // It's ugly to duplicate the code from delete(void *) above, but if
75 // we don't, g++ 6.3 can't figure out we're calling through it to
78 // In function 'void operator delete(void*, long unsigned int)':
79 // warning: deleting 'void*' is undefined [-Wdelete-incomplete]
83 free((void *)((char *)p - 8));
87 #endif /* COOKIE_BUG */