Created
February 27, 2013 20:29
-
-
Save Groogy/5051409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SFML.memory_usage | |
VALUE rbSFML::GetMemoryUsage( VALUE aSelf ) | |
{ | |
void* table = rb_mod_const_at( aSelf, 0 ); | |
VALUE list = rb_const_list( table ); | |
GetMemoryUsageInfo info; | |
info.memoryUsage = 0; | |
info.listPointer = RARRAY_PTR( list ); | |
info.listLength = RARRAY_LEN( list ); | |
for( size_t index = 0; index < info.listLength; index++ ) | |
{ | |
info.listPointer[ index ] = rb_const_get( aSelf, SYM2ID( info.listPointer[ index ] ) ); | |
} | |
VALUE ObjectSpaceModule = rb_const_get( rb_cObject, rb_intern( "ObjectSpace" ) ); | |
rb_block_call( ObjectSpaceModule, rb_intern( "each_object" ), 0, NULL, | |
( VALUE( * )( ... ) )GetMemoryUsageIterator, ( VALUE )&info ); | |
return SIZET2NUM( info.memoryUsage ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment