Class: AutoC::BDWAllocator

Inherits:
Object
  • Object
show all
Includes:
Entity, Singleton
Defined in:
lib/autoc/allocators.rb

Overview

Boehm-Demers-Weiser garbage-collecting memory handler www.hboehm.info/gc/

Constant Summary

Constants included from Entity

Entity::ReferenceSet

Instance Method Summary collapse

Methods included from Entity

#<=>, #complexity, #dependencies, #forward_declarations, #implementation, #interface, #position, #references, #total_dependencies, #total_references

Constructor Details

#initializeBDWAllocator

Returns a new instance of BDWAllocator.



40
# File 'lib/autoc/allocators.rb', line 40

def initialize = dependencies << SystemHeader.new('gc.h')

Instance Method Details

#allocate(type, count = 1, atomic: false, **kws) ⇒ Object



42
43
44
# File 'lib/autoc/allocators.rb', line 42

def allocate(type, count = 1, atomic: false, **kws)
  atomic ? "(#{type}*)GC_malloc_atomic((#{count})*sizeof(#{type}))" : "(#{type}*)GC_malloc((#{count})*sizeof(#{type}))"
end

#free(pointer) ⇒ Object



46
# File 'lib/autoc/allocators.rb', line 46

def free(pointer) = nil