Skip to content

Instantly share code, notes, and snippets.

@bradleyd
Created September 24, 2017 02:42
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 bradleyd/46cbdd81c29e1f4e612584442038707d to your computer and use it in GitHub Desktop.
Save bradleyd/46cbdd81c29e1f4e612584442038707d to your computer and use it in GitHub Desktop.
libc strtok
lib LibStrToken
fun strtok( input : LibC::Char*, delim : LibC::Char*) : LibC::Char*
end
module Test
class Run
def string_token(str, del)
LibStrToken.strtok(str, del)
end
end
end
puts Test::Run.new.string_token("This - is - split", "-")
### output
Invalid memory access (signal 11) at address 0x55dd555411e1
[0x55dd554e6115] *CallStack::print_backtrace:Int32 +117
[0x55dd554db3bd] __crystal_sigfault_handler +61
[0x7ff257a35670] ???
[0x7ff2570ca9d9] strtok +201
[0x55dd5551e500] *Test::Run#string_token<String, String>:Pointer(UInt8) +48
[0x55dd554cbe74] ???
[0x55dd554db2b9] main +41
[0x7ff25705a3f1] __libc_start_main +241
[0x55dd554cb75a] _start +42
[0x0] ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment