Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct {
- uint8_t* buf;
- size_t buflen;
- } API_t;
- void API_init_as_writer(API_t* p, uint8_t* buf, size_t buflen);
- data API -- empty decl (needs EmptyDataDecls extension)
- foreign import ccall unsafe "API.h API_init_as_writer"
- init :: Ptr API -> Ptr Word8 -> Int -> IO ()
- writer <- initWriter 1024 -- inits with buflen of 1024 via mallocPlainForeignPtrBytes
- writeSomething writer
- writeSomethingElse writer
- ...
- bs <- getByteString writer -- construct ByteString with PS
- writeFile "Some.file" bs
- bs <- ByteString.readFile("Some.file")
- reader <- initReader bs
- info1 <- readSomething reader
- info2 <- readSomethingElse reader
Add Comment
Please, Sign In to add comment