void kfree(uintptr_t* ptr) { /* Get block header */ block_header_t* hdr = (block_header_t*)((uintptr_t)ptr - sizeof(block_header_t)); hdr->flags = 0; /* Expand block left and right if needed */ expand_right(hdr); expand_left(hdr); }
void editor_map::resize(int width, int height, int x_offset, int y_offset, t_translation::t_terrain filler) { int old_w = w(); int old_h = h(); if (old_w == width && old_h == height && x_offset == 0 && y_offset == 0) { return; } // Determine the amount of resizing is required const int left_resize = -x_offset; const int right_resize = (width - old_w) + x_offset; const int top_resize = -y_offset; const int bottom_resize = (height - old_h) + y_offset; if(right_resize > 0) { expand_right(right_resize, filler); } else if(right_resize < 0) { shrink_right(-right_resize); } if(bottom_resize > 0) { expand_bottom(bottom_resize, filler); } else if(bottom_resize < 0) { shrink_bottom(-bottom_resize); } if(left_resize > 0) { expand_left(left_resize, filler); } else if(left_resize < 0) { shrink_left(-left_resize); } if(top_resize > 0) { expand_top(top_resize, filler); } else if(top_resize < 0) { shrink_top(-top_resize); } // fix the starting positions if(x_offset || y_offset) { for(size_t i = 0; i < MAX_PLAYERS+1; ++i) { if(startingPositions_[i] != map_location()) { startingPositions_[i].x -= x_offset; startingPositions_[i].y -= y_offset; } } } sanity_check(); }