Visual C++ Runtime: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
Line 83: | Line 83: | ||
One of the first things you'll want to do is implement new and delete operators. At first, you can't really implement them, and just need to have their stubs. Later on, when you get your memory manager working, you can fully implement them. Bellow are the stubs: |
One of the first things you'll want to do is implement new and delete operators. At first, you can't really implement them, and just need to have their stubs. Later on, when you get your memory manager working, you can fully implement them. Bellow are the stubs: |
||
< |
<syntaxhighlight lang="C">void* __cdecl operator new(size_t size) |
||
{ |
{ |
||
// Allocate memory |
// Allocate memory |
||
Line 113: | Line 113: | ||
// Release allocated memory |
// Release allocated memory |
||
}</ |
}</syntaxhighlight> |
||
If you'll want to use placement new, then you'll need to put the following implementation into a header file, and include it whenever you need it. |
If you'll want to use placement new, then you'll need to put the following implementation into a header file, and include it whenever you need it. |
||
< |
<syntaxhighlight lang="C">inline void* __cdecl operator new(size_t size, void* address) |
||
{ |
{ |
||
return address; |
return address; |
||
}</ |
}</syntaxhighlight> |
||