def malloc_nonmovable(self, TYPE, n=None, zero=False): typeid = self.get_type_id(TYPE) if not self.gc.can_malloc_nonmovable(): return lltype.nullptr(TYPE) addr = self.gc.malloc_nonmovable(typeid, n, zero=zero) result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE)) if not self.gc.malloc_zero_filled: gctypelayout.zero_gc_pointers(result) return result
def malloc(self, TYPE, n=None, flavor='gc', zero=False, track_allocation=True): if flavor == 'gc': typeid = self.get_type_id(TYPE) addr = self.gc.malloc(typeid, n, zero=zero) result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE)) if not self.gc.malloc_zero_filled: gctypelayout.zero_gc_pointers(result) return result else: return lltype.malloc(TYPE, n, flavor=flavor, zero=zero, track_allocation=track_allocation)