Skip to content

boggle/coffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coffer 0.0.2
============

Small package for copying between a memory range managed
by C code and Go Buffers.  

Requires installation of github.com/boggle/gonewrong

Status: Only barely tested right now but it appears to be working :-)

Typical Usage:

import buffer
import unsafe.coffer
import io

var start uintptr
var sz int
var buf io.Buffer

coffer := coffer.NewPtrCoffer(start, sz)

// Read Bytes from C
buf.ReadFrom(coffer)
bytes := buf.Bytes() 

// Write Bytes to C
buf.WriteTo(coffer)

// or
coffer.Write(buf.Bytes())

// Reset to start of memory range
coffer.Seek(0, 0)

// Subsequent Read, Write, or Seek will fail
// Does *NOT* free
coffer.Close()

// Variant: Allocs using C.malloc and frees on Close()
// (independent from Go's GC)
coffer := coffer.NewMemCoffer(sz)
Coffer.Close()

// Have fun!





About

Package for copying data between memory ranges managed by C code and Go Buffers (uses cgo)

Resources

License

Stars

Watchers

Forks

Packages

No packages published