Created
September 12, 2016 08:58
-
-
Save nurse/f9a068c2e84f9324f7626795b212302e to your computer and use it in GitHub Desktop.
Create large string
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
require 'fiddle' | |
def create_large_string(size) | |
func = Fiddle::Function.new(Fiddle::Handle::DEFAULT['rb_str_new'], [Fiddle::TYPE_VOIDP,Fiddle::TYPE_LONG], Fiddle::TYPE_VOIDP) | |
# returns fast on environments whose malloc delays the actual allocation | |
ptr = func.call(nil, size) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment