d3dxof: GetName can be used to just get the name length.

This commit is contained in:
Dylan Smith 2011-04-20 16:20:53 -04:00 committed by Alexandre Julliard
parent 10fbf5f542
commit 8cae5c2312
1 changed files with 25 additions and 5 deletions

View File

@ -728,13 +728,23 @@ static HRESULT WINAPI IDirectXFileDataImpl_GetName(IDirectXFileData* iface, LPST
{ {
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface; IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
DWORD len;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen); TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
if (!pstrNameBuf) if (!pdwBufLen)
return DXFILEERR_BADVALUE; return DXFILEERR_BADVALUE;
strcpy(pstrNameBuf, This->pobj->name); len = strlen(This->pobj->name);
if (len)
len++;
if (pstrNameBuf) {
if (*pdwBufLen < len)
return DXFILEERR_BADVALUE;
CopyMemory(pstrNameBuf, This->pobj->name, len);
}
*pdwBufLen = len;
return DXFILE_OK; return DXFILE_OK;
} }
@ -962,15 +972,25 @@ static ULONG WINAPI IDirectXFileDataReferenceImpl_Release(IDirectXFileDataRefere
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen) static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
{ {
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface; IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
DWORD len;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen); TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
if (!pstrNameBuf) if (!pdwBufLen)
return DXFILEERR_BADVALUE; return DXFILEERR_BADVALUE;
strcpy(pstrNameBuf, This->ptarget->name); len = strlen(This->ptarget->name);
if (len)
len++;
return DXFILEERR_BADVALUE; if (pstrNameBuf) {
if (*pdwBufLen < len)
return DXFILEERR_BADVALUE;
CopyMemory(pstrNameBuf, This->ptarget->name, len);
}
*pdwBufLen = len;
return DXFILE_OK;
} }
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference* iface, LPGUID pGuid) static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference* iface, LPGUID pGuid)