Cosmetic: Copyright years were updated
[ode.git] / ode / src / odeou.cpp
blob61f9cfb795be6ce4ea71787706bb3fb600bf117b
1 /*************************************************************************
2 * *
3 * OU library interface file for Open Dynamics Engine, *
4 * Copyright (C) 2008-2022 Oleh Derevenko. All rights reserved. *
5 * Email: odar@eleks.com (change all "a" to "e") *
6 * *
7 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
8 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
9 * *
10 * *
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of EITHER: *
13 * (1) The GNU Lesser General Public License as published by the Free *
14 * Software Foundation; either version 2.1 of the License, or (at *
15 * your option) any later version. The text of the GNU Lesser *
16 * General Public License is included with this library in the *
17 * file LICENSE.TXT. *
18 * (2) The BSD-style license that is included with this library in *
19 * the file LICENSE-BSD.TXT. *
20 * *
21 * This library is distributed in the hope that it will be useful, *
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
24 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
25 * *
26 *************************************************************************/
30 ODE interface to OU library implementation.
35 #include <ode/common.h>
36 #include <ode/memory.h>
37 #include "config.h"
38 #include "odeou.h"
42 #if dOU_ENABLED
45 using _OU_NAMESPACE::EASSERTIONFAILURESEVERITY;
46 using _OU_NAMESPACE::AFS__MAX;
47 using _OU_NAMESPACE::CMemoryManagerCustomization;
48 using _OU_NAMESPACE::CAssertionCheckCustomization;
51 BEGIN_NAMESPACE_OU();
52 template<>
53 const char *const CEnumUnsortedElementArray<EASSERTIONFAILURESEVERITY, AFS__MAX, const char *>::m_aetElementArray[] =
55 "assert", // AFS_ASSERT,
56 "check", // AFS_CHECK,
58 END_NAMESPACE_OU();
60 static const CEnumUnsortedElementArray<EASSERTIONFAILURESEVERITY, AFS__MAX, const char *> g_aszAssertionFailureSeverityNames;
63 static void _OU_CONVENTION_CALLBACK ForwardOUAssertionFailure(EASSERTIONFAILURESEVERITY fsFailureSeverity,
64 const char *szAssertionExpression, const char *szAssertionFileName, unsigned int uiAssertionSourceLine)
66 dDebug(d_ERR_IASSERT, "Assertion failure in OU Library. Kind: %s, expression: \"%s\", file: \"%s\", line: %u",
67 g_aszAssertionFailureSeverityNames.Encode(fsFailureSeverity),
68 szAssertionExpression, szAssertionFileName, uiAssertionSourceLine);
72 static void *_OU_CONVENTION_CALLBACK ForwardOUMemoryAlloc(size_t nBlockSize)
74 return dAlloc(nBlockSize);
77 static void *_OU_CONVENTION_CALLBACK ForwardOUMemoryRealloc(void *pv_ExistingBlock, size_t nBlockNewSize)
79 return dRealloc(pv_ExistingBlock, 0, nBlockNewSize);
82 static void _OU_CONVENTION_CALLBACK ForwardOUMemoryFree(void *pv_ExistingBlock)
84 return dFree(pv_ExistingBlock, 0);
88 bool COdeOu::DoOUCustomizations()
90 CMemoryManagerCustomization::CustomizeMemoryManager(&ForwardOUMemoryAlloc,
91 &ForwardOUMemoryRealloc, &ForwardOUMemoryFree);
93 CAssertionCheckCustomization::CustomizeAssertionChecks(&ForwardOUAssertionFailure);
95 return true;
98 void COdeOu::UndoOUCustomizations()
100 CAssertionCheckCustomization::CustomizeAssertionChecks(NULL);
102 CMemoryManagerCustomization::CustomizeMemoryManager(NULL, NULL, NULL);
106 #endif // dOU_ENABLED