[PATCH 06/10] d3dx9: Factor out set_value() function.
Matteo Bruni
matteo.mystral at gmail.com
Tue Nov 12 12:56:15 CST 2019
On Thu, Nov 7, 2019 at 10:19 PM Paul Gofman <gofmanp at gmail.com> wrote:
> +static HRESULT set_string(char **param_data, const char *string)
> +{
> + HeapFree(GetProcessHeap(), 0, *param_data);
> + *param_data = HeapAlloc(GetProcessHeap(), 0, strlen(string) + 1);
> + if (!*param_data)
> + {
> + ERR("Out of memory.\n");
> + return E_OUTOFMEMORY;
> + }
> + strcpy(*param_data, string);
> + return D3D_OK;
> +}
I know that this is not new code but I have a couple of comments.
Another option here would be to only free the old memory after the new
allocation succeeds. I guess it's not particularly important since the
situation must be pretty hopeless if allocating a string fails.
Regardless, you should probably make use of the helpers from heap.h.
More information about the wine-devel
mailing list