Now that linear_realloc() is unused, remove it. It is not an actual
realloc, will always allocate new memory and copy data around -- and
had a big warning about it in the documentation.
In the couple of uses we had before, the client code knew the size,
so it could be changed to perform the allocation and the copy by
themselves. The client code keeping the size is the recommended
way here.
This will allow us remove linear_size_chunk later.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25280>
return PTR_FROM_HEADER(get_header(node)->parent);
}
-void *
-linear_realloc(linear_ctx *ctx, void *old, unsigned new_size)
-{
- unsigned old_size = 0;
- ralloc_header *new_ptr;
-
- new_ptr = linear_alloc_child(ctx, new_size);
-
- if (unlikely(!old))
- return new_ptr;
-
- old_size = ((linear_size_chunk*)old)[-1].size;
-
- if (likely(new_ptr && old_size))
- memcpy(new_ptr, old, MIN2(old_size, new_size));
-
- return new_ptr;
-}
-
/* All code below is pretty much copied from ralloc and only the alloc
* calls are different.
*/
void *ralloc_parent_of_linear_context(linear_ctx *ctx);
/**
- * Same as realloc except that the linear allocator doesn't free child nodes,
- * so it's reduced to memory duplication. It's used in places where
- * reallocation is required. Don't use it often. It's much slower than
- * realloc.
- */
-void *linear_realloc(linear_ctx *ctx, void *old, unsigned new_size);
-
-/**
* Do a fast allocation of an array from the linear context and initialize it to zero.
*
* Similar to \c calloc, but does not initialize the memory to zero.