/* On success, return a pointer to the newly allocated, or recycled, memory. On error, return -errno. The following error codes are defined: -ENOMEM - Not enough memory to allocate runlist array. -EINVAL - Invalid parameters were passed in.  */
static runlist_element* ntfs_rl_realloc(runlist_element *rl, int old_size, int new_size)
/* On success, return a pointer to the newly allocated, or recycled, memory. On error, return -errno. The following error codes are defined: -ENOMEM - Not enough memory to allocate runlist array. -EINVAL - Invalid parameters were passed in.  */
static runlist_element* ntfs_rl_realloc(runlist_element *rl, int old_size, int new_size)
{
	runlist_element *new_rl;
	old_size = PAGE_ALIGN(old_size * sizeof(*rl));
	new_size = PAGE_ALIGN(new_size * sizeof(*rl));
	if (old_size == new_size)
		return rl;
	new_rl = ntfs_malloc_nofs(new_size);
	if (unlikely(!new_rl))
		return ERR_PTR(-ENOMEM);
	if (likely(rl != NULL)) {
		if (unlikely(old_size > new_size))
			old_size = new_size;
		memcpy(new_rl, rl, old_size);
		ntfs_free(rl);
	}
	return new_rl;
}