Skip to content

Commit b0f00b3

Browse files
Initial Release of the Intel Graphics Compiler
Signed-off-by: achand7 <[email protected]>
1 parent 5ea43b4 commit b0f00b3

File tree

1,708 files changed

+833483
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,708 files changed

+833483
-0
lines changed

3d/common/iStdLib/Alloc.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*===================== begin_copyright_notice ==================================
2+
3+
Copyright (c) 2017 Intel Corporation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a
6+
copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included
14+
in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
24+
25+
======================= end_copyright_notice ==================================*/
26+
#pragma once
27+
#include "Debug.h"
28+
29+
#ifdef __cplusplus
30+
31+
namespace iSTD
32+
{
33+
34+
35+
/*****************************************************************************\
36+
37+
Function:
38+
SafeDelete
39+
40+
Description:
41+
Safe "delete ptr;"
42+
43+
Input:
44+
Type &ptr - pointer to memory to delete
45+
46+
Output:
47+
Type &ptr
48+
49+
\*****************************************************************************/
50+
template <class Type>
51+
inline void SafeDelete( Type &ptr )
52+
{
53+
if( ptr )
54+
{
55+
#if defined( _DEBUG ) && !defined( NO_EXCEPTION_HANDLING )
56+
#if defined( __GNUC__ )
57+
try
58+
{
59+
delete ptr;
60+
}
61+
catch (...)
62+
{
63+
ASSERT(0);
64+
}
65+
#else // defined( __GNUC__ )
66+
__try
67+
{
68+
delete ptr;
69+
}
70+
__except (1)
71+
{
72+
ASSERT(0);
73+
}
74+
#endif // defined( __GNUC__ )
75+
#else // defined( _DEBUG ) && !defined( NO_EXCEPTION_HANDLING )
76+
delete ptr;
77+
#endif // defined( _DEBUG ) && !defined( NO_EXCEPTION_HANDLING )
78+
ptr = 0;
79+
}
80+
};
81+
82+
/*****************************************************************************\
83+
84+
Function:
85+
SafeDeleteArray
86+
87+
Description:
88+
Safe "delete[] ptr;"
89+
90+
Input:
91+
Type &ptr - pointer to memory to delete
92+
93+
Output:
94+
Type &ptr
95+
96+
\*****************************************************************************/
97+
template <class Type>
98+
inline void SafeDeleteArray( Type &ptr )
99+
{
100+
if( ptr )
101+
{
102+
#if defined( _DEBUG ) && !defined( NO_EXCEPTION_HANDLING )
103+
#if defined( __GNUC__ )
104+
try
105+
{
106+
delete[] ptr;
107+
}
108+
catch (int e)
109+
{
110+
ASSERT(0);
111+
}
112+
#else // defined( __GNUC__ )
113+
__try
114+
{
115+
delete[] ptr;
116+
}
117+
__except (1)
118+
{
119+
ASSERT(0);
120+
}
121+
#endif // defined( __GNUC__ )
122+
#else // defined( _DEBUG ) && !defined( NO_EXCEPTION_HANDLING )
123+
delete[] ptr;
124+
#endif // defined( _DEBUG ) && !defined( NO_EXCEPTION_HANDLING )
125+
ptr = 0;
126+
}
127+
};
128+
129+
} // iSTD
130+
131+
#endif // __cplusplus

0 commit comments

Comments
 (0)