Documentation
¶
Overview ¶
Package sim simulates client application working with the heap using malloc(3) API: malloc() and free().
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpFunc ¶
type OpFunc func(int) operation
OpFunc generates a malloc or free operations. The meaning of the integer parameter depends on the operation being generated: malloc(n) means generate a malloc operation to allocated n-bytes, free(n) means generate a free operation to release n-th allocation available at the moment of running the free operation.
type Option ¶
type Option func(*Simulator)
Option modifies simulator configuration in some way, e.g., set manual operations.
type Simulator ¶
type Simulator struct {
// contains filtered or unexported fields
}
Simulator runs malloc operations on the heap. The operation can be random:
s := sim.NewSimulator(h, num)
or manually set:
s := sim.NewSimulator(h, 0, sim.WithOps([]string{"+10"})
func NewSimulator ¶
NewSimulator creates a heap simulator to generate num random operations. Use WithOps to override random operations with a list of manual operation in the form "op,op,..." where "op" is either "+N" to allocate a block of size N or "-N" to free N-th currently available allocation.