Skip to content

Instantly share code, notes, and snippets.

@nurse
Created September 12, 2016 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurse/f9a068c2e84f9324f7626795b212302e to your computer and use it in GitHub Desktop.
Save nurse/f9a068c2e84f9324f7626795b212302e to your computer and use it in GitHub Desktop.
Create large string
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