Skip to content

Instantly share code, notes, and snippets.

@Groogy
Created February 27, 2013 20:29
Show Gist options
  • Save Groogy/5051409 to your computer and use it in GitHub Desktop.
Save Groogy/5051409 to your computer and use it in GitHub Desktop.
// 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