github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/mm/xxx/fallback.go (about)

     1  // DO NOT EDIT
     2  // GENERATED CODE
     3  package xxx
     4  
     5  import "github.com/egonelbre/exp/mm"
     6  
     7  type Fallback struct {
     8  	Primary  mm.Malloc
     9  	Fallback *mm.Region
    10  }
    11  
    12  func (m *Fallback) Alignment() int {
    13  	return 4
    14  }
    15  
    16  func (m *Fallback) Alloc(size int) unsafe.Pointer {
    17  	if size == 0 {
    18  		return nil
    19  	}
    20  	p := m.Primary.Allocate(size)
    21  	if p == nil {
    22  		p = m.Fallback.Allocate(size)
    23  	}
    24  	return p
    25  }