Skip to content

Instantly share code, notes, and snippets.

@neilpa
neilpa / CStringArray.swift
Last active August 7, 2020 02:24
Swift wrappers for C functions taking char** arguments
// Usage
let argv = CStringArray(["ls", "/"])
posix_spawnp(nil, argv.pointers[0], nil, nil, argv.pointers, nil)
// Is this really the best way to extend the lifetime of C-style strings? The lifetime
// of those passed to the String.withCString closure are only guaranteed valid during
// that call. Tried cheating this by returning the same C string from the closure but it
// gets dealloc'd almost immediately after the closure returns. This isn't terrible when
// dealing with a small number of constant C strings since you can nest closures. But
@neilpa
neilpa / keybase.md
Created March 24, 2014 22:08
keybase.io proof

Keybase proof

I hereby claim:

  • I am neilpa on github.
  • I am neilpa (https://keybase.io/neilpa) on keybase.
  • I have a public key whose fingerprint is 206A 9788 172B A7F0 C5DD 0930 5BDE 41AD 8199 B734

To claim this, I am signing this object: