Set number of returned modes early in the process.

Let's be a bit pedantic here, if the number of returned modes is Zero,
then just free resources and get out.

Signed-off-by: Christopher Michael <cp.michael@samsung.com>

SVN revision: 83617
This commit is contained in:
Christopher Michael 2013-02-05 08:53:18 +00:00 committed by Christopher Michael
parent cc2b953b65
commit f317906408
1 changed files with 12 additions and 3 deletions

View File

@ -639,6 +639,18 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num)
{
Ecore_X_Randr_Mode_Info **ret = NULL;
/* set the returned number of modes */
if (num) *num = res->nmode;
/* if we did not get any modes from X, then cleanup and return */
if (res->nmode == 0)
{
/* free the resources */
XRRFreeScreenResources(res);
return NULL;
}
/* try to allocate space for our return variable */
if ((ret = (Ecore_X_Randr_Mode_Info **)
malloc(res->nmode * sizeof(Ecore_X_Randr_Mode_Info *))))
@ -682,9 +694,6 @@ ecore_x_randr_modes_info_get(Ecore_X_Window root, int *num)
}
}
/* set the returned number of modes */
if ((ret) && (num)) *num = res->nmode;
/* free the resources */
XRRFreeScreenResources(res);