def alloc_mem(self, size): """allocate memory and return addr or 0 if no more memory""" # align size to 4 bytes size = (size + 3) & ~3 # find best free chunk chunk, left = self._find_best_chunk(size) # out of memory? if chunk == None: log_mem_alloc.warn("[alloc: NO MEMORY for %06x bytes]", size) return 0 # remove chunk from free list # is something left? addr = chunk.addr if left == 0: self._remove_chunk(chunk) else: left_chunk = MemoryChunk(addr + size, left) self._replace_chunk(chunk, left_chunk) # add to valid allocs map self.addrs[addr] = size self.free_bytes -= size # erase memory self.mem.clear_block(addr, size, 0) log_mem_alloc.info("[alloc @%06x-%06x: %06x bytes] %s", addr, addr+size, size, self._stat_info()) return addr
def alloc_mem(self, size): """allocate memory and return addr or 0 if no more memory""" # align size to 4 bytes size = (size + 3) & ~3 # find best free chunk chunk, left = self._find_best_chunk(size) # out of memory? if chunk == None: log_mem_alloc.warn("[alloc: NO MEMORY for %06x bytes]", size) return 0 # remove chunk from free list # is something left? addr = chunk.addr if left == 0: self._remove_chunk(chunk) else: left_chunk = MemoryChunk(addr + size, left) self._replace_chunk(chunk, left_chunk) # add to valid allocs map self.addrs[addr] = size self.free_bytes -= size # erase memory self.mem.clear_block(addr, size, 0) log_mem_alloc.info("[alloc @%06x-%06x: %06x bytes] %s", addr, addr + size, size, self._stat_info()) return addr
def _dump_orphan(self, addr, size): log_mem_alloc.warn("orphan: [@%06x +%06x %06x]" % (addr, size, addr + size)) if self.label_mgr != None: labels = self.label_mgr.get_intersecting_labels(addr, size) for l in labels: log_mem_alloc.warn("-> %s", l)
def _dump_orphan(self, addr, size): log_mem_alloc.warn("orphan: [@%06x +%06x %06x]" % (addr, size, addr + size)) labels = self.label_mgr.get_intersecting_labels(addr, size) for l in labels: log_mem_alloc.warn("-> %s", l)