Example #1
0
func (t *T) rand_varchar(min, max int) []byte {
	bytes := t.rand_bytes(4)
	s := slice.AsSlice(&bytes)
	length := int(*(*uint32)(s.Array))
	length = (length % (max)) + min
	return t.rand_bytes(length)
}
Example #2
0
File: fmap.go Project: postfix/fs2
func new_ctrlblk(bytes []byte, blksize uint32) (cb *ctrlblk) {
	back := slice.AsSlice(&bytes)
	cb = (*ctrlblk)(back.Array)
	cb.meta.blksize = blksize
	cb.meta.free_head = 0
	cb.meta.free_len = 0
	MemClr(cb.user[:])
	return cb
}
Example #3
0
func (n *internal) ptrs_uint64s() []uint64 {
	keySize := int(n.meta.keySize)
	keyCap := int(n.meta.keyCap)
	s := keyCap * keySize
	e := s + keyCap*ptrSize
	bytes := n.bytes[s:e]
	sl := slice.AsSlice(&bytes)
	sl.Len = int(n.meta.keyCount)
	sl.Cap = sl.Len
	return *sl.AsUint64s()
}
Example #4
0
File: fmap.go Project: postfix/fs2
func (self *BlockFile) zero(offset uint64, n int) (uint64, error) {
	for i := 0; i < n; i++ {
		err := self.Do(offset+uint64(i*self.blksize), 1, func(block []byte) error {
			ptr := slice.AsSlice(&block).Array
			memClr(ptr, uintptr(len(block)))
			return nil
		})
		if err != nil {
			return 0, err
		}
	}
	return offset, nil
}
Example #5
0
func loadBaseMeta(backing []byte) *baseMeta {
	back := slice.AsSlice(&backing)
	return (*baseMeta)(back.Array)
}
Example #6
0
func asInternal(backing []byte) *internal {
	back := slice.AsSlice(&backing)
	return (*internal)(back.Array)
}
Example #7
0
File: fmap.go Project: postfix/fs2
// Zero the bytes of the passed in slice. It uses the length not the
// capacity of the slice. It uses the libc function memset under the
// hood to do this. Go has an implementation of this function in
// assembly in the runtime package but I could not find a nice way to
// expose it. So here is the libc version exposed (via several method
// calls and the cgo interface).
func MemClr(bytes []byte) {
	memClr(slice.AsSlice(&bytes).Array, uintptr(len(bytes)))
}
Example #8
0
File: fmap.go Project: postfix/fs2
func load_ctrlblk(bytes []byte) (cb *ctrlblk, err error) {
	back := slice.AsSlice(&bytes)
	cb = (*ctrlblk)(back.Array)
	return cb, nil
}
Example #9
0
func asCtrl(backing []byte) *varCtrl {
	assert_len(backing, varCtrlSize)
	back := slice.AsSlice(&backing)
	return (*varCtrl)(back.Array)
}
Example #10
0
File: fmap.go Project: postfix/fs2
func loadFreeBlk(bytes []byte) *freeblk {
	free_s := slice.AsSlice(&bytes)
	return (*freeblk)(free_s.Array)
}
Example #11
0
File: const.go Project: postfix/fs2
func AsFlag(bytes []byte) Flag {
	back := slice.AsSlice(&bytes)
	return *(*Flag)(back.Array)
}
Example #12
0
func (t *T) key(bytes []byte) uint64 {
	t.assert("bytes must have length 8", len(bytes) == 8)
	s := slice.AsSlice(&bytes)
	return *(*uint64)(s.Array)
}
Example #13
0
func asRunMeta(backing []byte) *varRunMeta {
	assert_len(backing, varRunMetaSize)
	back := slice.AsSlice(&backing)
	return (*varRunMeta)(back.Array)
}
Example #14
0
func asFree(backing []byte) *varFree {
	assert_len(backing, varFreeSize)
	back := slice.AsSlice(&backing)
	return (*varFree)(back.Array)
}
Example #15
0
func loadLeafMeta(backing []byte) *leafMeta {
	back := slice.AsSlice(&backing)
	return (*leafMeta)(back.Array)
}
Example #16
0
func asLeaf(backing []byte) *leaf {
	back := slice.AsSlice(&backing)
	return (*leaf)(back.Array)
}
Example #17
0
File: list.go Project: postfix/fs2
func (l *List) asIdx(bytes []byte) *idxBlk {
	assert_len(bytes, ctrlBlkSize)
	back := slice.AsSlice(&bytes)
	return (*idxBlk)(back.Array)
}