Kea 2.7.5
newhook.cc
Go to the documentation of this file.
1// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <stdlib.h>
10
11#include <new>
12#include <stdexcept>
13
15
16#ifdef ENABLE_CUSTOM_OPERATOR_NEW
17void*
18operator new(size_t size) throw(std::bad_alloc) {
21 throw std::bad_alloc();
22 }
23 void* p = malloc(size);
24 if (p == NULL) {
25 throw std::bad_alloc();
26 }
27 return (p);
28}
29
30void
31operator delete(void* p) throw() {
32 if (p != NULL) {
33 free(p);
34 }
35}
36#endif
37
38namespace isc {
39namespace util {
40namespace unittests {
41bool force_throw_on_new = false;
43}
44}
45}
size_t throw_size_on_new
The allocation size that triggers an exception in the special operator new.
Definition newhook.cc:42
bool force_throw_on_new
Switch to enable the use of special operator new.
Definition newhook.cc:41
Defines the logger used by the top-level component of kea-lfc.
Enable the use of special operator new that throws for testing.