Beispiel #1
0
Datei: tdb.go Projekt: ypb/gotdb
// Close calls tdb_close() on the C ctx pointer contained in DB struct,
// rendering it invalid in all other instances of the same path name (see New).
// Only on success does it return nil Error along with integer SUCCESS status.
// And here is trivially meaningless cgo signature of the original C function:
//
// func tdb_close() C.int
func (file DB) Close() Error {
	dbg := file.db.dbg
	if dbg {
		println("tdb.Close()", file.String())
	}
	if file.db.cld {
		if dbg {
			println("  tdb.Close()", "db.ctx =", file.db.ctx)
		}
		return mkError(ERR_IO, "tdb.Close() already closed")
	}
	var status = int(C.tdb_close(file.db.ctx))
	if dbg {
		println("  tdb.Close()", "tdb_close() ->", status)
	}
	if status == SUCCESS {
		file.db.cld = true
		// for now, while testing let us hold on with that one
		// file.db.ctx = nil // argh! this does not stack up!
		return nil
	}
	// TODO: extract proper error string
	return mkError(status, "tdb.Close() SUCCESS not")
}
Beispiel #2
0
func (db *TrailDB) Close() {
	C.tdb_close(db.db)
}