def malloc_resizable_buffer(self, TYPE, n): typeid = self.get_type_id(TYPE) addr = self.gc.malloc(typeid, n) 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_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): 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)
def malloc(self, TYPE, n=None, flavor='gc', zero=False): 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)
def coalloc(self, TYPE, coallocator, size=None, zero=False): if hasattr(self.gc, "coalloc_fixedsize_clear"): typeid = self.get_type_id(TYPE) addr = self.gc.malloc(typeid, size, zero=zero, coallocator=coallocator) result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE)) if not self.gc.malloc_zero_filled: gctypelayout.zero_gc_pointers(result) return result return self.malloc(TYPE, size, 'gc', zero)