Use memcpy instead of strndup() as we know the length of the string.

Also fixes compilation on Mac OS X where strndup() is not defined.


SVN revision: 56341
This commit is contained in:
Vincent Torri 2011-01-28 09:17:54 +00:00
parent 5459ecbcee
commit 6ef596d4d5
1 changed files with 5 additions and 3 deletions

View File

@ -406,11 +406,13 @@ ecore_x_randr_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode)
ret->vTotal = res->modes[i].vTotal;
ret->name = NULL;
ret->nameLength = 0;
if (res->modes[i].nameLength > 0)
if (res->modes[i].nameLength > 0)
{
ret->nameLength = res->modes[i].nameLength;
ret->name = strndup(res->modes[i].name,
res->modes[i].nameLength);
ret->name = malloc(res->modes[i].nameLength + 1);
if (ret->name)
memcpy(ret->name, res->modes[i].name,
res->modes[i].nameLength + 1);
}
ret->modeFlags = res->modes[i].modeFlags;
break;