Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created January 30, 2015 23:32
Show Gist options
  • Save chadaustin/bb9a7134bc6743aa6c6c to your computer and use it in GitHub Desktop.
Save chadaustin/bb9a7134bc6743aa6c6c to your computer and use it in GitHub Desktop.
grow :: (# State# RealWorld, Buffer# #) -> (# State# RealWorld, Buffer# #)
grow (# s0, (# _, size, cap, _ #) #) =
let newCap# = cap *# 2# in
let (IO iorep) = mallocForeignPtrBytes (I# newCap#) in
case iorep s0 of {
(# s1, fp@(ForeignPtr addr# _) #) -> (# s1, (# addr#, size, newCap#, fp #) #) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment