On 2016-08-06 16:29, Aaryaman Vasishta wrote:
> +������ ������ while (!done)
> +������ ������ {
> +������ ������ ������ ������ if (FAILED(hr = IDirect3DRMFrame3_GetParent(frame, &parent_frame))) What happens if GetScene is called on the root frame? Does it return itself or NULL or an error?
> +������ ������ ������ ������ ������ ������ return hr;
> +������ ������ ������ ������ if (parent_frame)
> +������ ������ ������ ������ {
> +������ ������ ������ ������ ������ ������ frame = parent_frame;
> +������ ������ ������ ������ ������ ������ IDirect3DRMFrame3_Release(parent_frame);
> +������ ������ ������ ������ }
> +������ ������ ������ ������ else
> +������ ������ ������ ������ ������ ������ done = TRUE;
> +������ ������ }
You can eliminate the done variable from this loop by replacing it with a break:
for (;;)
{
������ ������ if (FAILED(hr = IDirect3DRMFrame3_GetParent(frame, &parent_frame))) ������ ������ ������ ������ return hr;
������ ������ if (parent_frame)
������ ������ {
������ ������ ������ ������ frame = parent_frame;
������ ������ ������ ������ IDirect3DRMFrame3_Release(parent_frame);
������ ������ }
������ ������ else
������ ������ ������ ������ break;
}
I originally thought about a do {} while(parent_frame); kind of construct but that doesn't gain you much because you need the if check anyway to release parent_frame.
It's not nice to call GetParent in the next iteration after you release the frame, but so far I haven't come up with an implementation that avoids that and isn't terribly ugly. I'll keep thinking.