1 /*************************************************************************
3 * OU library interface file for Open Dynamics Engine, *
4 * Copyright (C) 2008 Oleh Derevenko. All rights reserved. *
5 * Email: odar@eleks.com (change all "a" to "e") *
7 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
8 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
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 *
18 * (2) The BSD-style license that is included with this library in *
19 * the file LICENSE-BSD.TXT. *
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. *
26 *************************************************************************/
30 ODE interface to OU library implementation.
35 #include <ode/common.h>
36 #include <ode/memory.h>
45 const char *const CEnumUnsortedElementArray
<EASSERTIONFAILURESEVERITY
, AFS__MAX
, const char *>::m_aetElementArray
[] =
47 "assert", // AFS_ASSERT,
48 "check", // AFS_CHECK,
50 static const CEnumUnsortedElementArray
<EASSERTIONFAILURESEVERITY
, AFS__MAX
, const char *> g_aszAssertionFailureSeverityNames
;
53 static void _OU_CONVENTION_CALLBACK
ForwardOUAssertionFailure(EASSERTIONFAILURESEVERITY fsFailureSeverity
,
54 const char *szAssertionExpression
, const char *szAssertionFileName
, unsigned int uiAssertionSourceLine
)
56 dDebug(d_ERR_IASSERT
, "Assertion failure in OU Library. Kind: %s, expression: \"%s\", file: \"%s\", line: %u",
57 g_aszAssertionFailureSeverityNames
.Encode(fsFailureSeverity
),
58 szAssertionExpression
, szAssertionFileName
, uiAssertionSourceLine
);
62 static void *_OU_CONVENTION_CALLBACK
ForwardOUMemoryAlloc(size_t nBlockSize
)
64 return dAlloc(nBlockSize
);
67 static void *_OU_CONVENTION_CALLBACK
ForwardOUMemoryRealloc(void *pv_ExistingBlock
, size_t nBlockNewSize
)
69 return dRealloc(pv_ExistingBlock
, 0, nBlockNewSize
);
72 static void _OU_CONVENTION_CALLBACK
ForwardOUMemoryFree(void *pv_ExistingBlock
)
74 return dFree(pv_ExistingBlock
, 0);
78 bool COdeOu::DoOUCustomizations()
80 CMemoryManagerCustomization::CustomizeMemoryManager(&ForwardOUMemoryAlloc
,
81 &ForwardOUMemoryRealloc
, &ForwardOUMemoryFree
);
83 CAssertionCheckCustomization::CustomizeAssertionChecks(&ForwardOUAssertionFailure
);
88 void COdeOu::UndoOUCustomizations()
90 CAssertionCheckCustomization::CustomizeAssertionChecks(NULL
);
92 CMemoryManagerCustomization::CustomizeMemoryManager(NULL
, NULL
, NULL
);