You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# No free function and no call to free - the native memory will leak if the pointer is garbage collectedpointer=Fiddle::Pointer.malloc(size)
The above approach is what's used in this library, for example:
csbi=Fiddle::Pointer.malloc(24)
Correct usage, not resulting in a memory leak, taken from the Fiddle docs:
# Automatically freeing the pointer when the block is exited - recommendedFiddle::Pointer.malloc(24,Fiddle::RUBY_FREE)do |csbi|
@GetConsoleScreenBufferInfo.Call(@hConsoleHandle,csbi)x,y=csbi[4,4].unpack('SS')endx=dpos@SetConsoleCursorPosition.Call(@hConsoleHandle,y*65536+x)@_rl_last_c_pos=dpos
The text was updated successfully, but these errors were encountered:
Looking at the Fiddle docs here: https://docs.ruby-lang.org/en/master/Fiddle/Pointer.html
We can see an example incorrect usage resulting in a memory leak:
The above approach is what's used in this library, for example:
Correct usage, not resulting in a memory leak, taken from the Fiddle docs:
The text was updated successfully, but these errors were encountered: