Re: [PATCH 5/5] d3dx9: Correctly handle out of memory conditions while reallocating children array.
On 26 August 2014 16:13, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
@@ -338,15 +338,20 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
while (SUCCEEDED(ret = IDirectXFileData_GetNextObject(object->dxfile_data, &data_object))) ... + new_children = HeapReAlloc(GetProcessHeap(), 0, object->children, + sizeof(*object->children) * (object->nb_children + 1)); While I suspect this is hardly the only thing wrong with xfile.c, it seems suboptimal to grow the array by 1 each time you go through the loop.
2014-08-26 16:30 GMT+02:00 Henri Verbeet <hverbeet(a)gmail.com>:
On 26 August 2014 16:13, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
@@ -338,15 +338,20 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
while (SUCCEEDED(ret = IDirectXFileData_GetNextObject(object->dxfile_data, &data_object))) ... + new_children = HeapReAlloc(GetProcessHeap(), 0, object->children, + sizeof(*object->children) * (object->nb_children + 1)); While I suspect this is hardly the only thing wrong with xfile.c, it seems suboptimal to grow the array by 1 each time you go through the loop.
Yeah, it should start at some size greater than 1 (no idea about typical children count here though) and then grow exponentially. I guess that can be a separate patch, but I can also add it to this one and resend if preferred.
2014-08-26 16:58 GMT+02:00 Matteo Bruni <matteo.mystral(a)gmail.com>:
2014-08-26 16:30 GMT+02:00 Henri Verbeet <hverbeet(a)gmail.com>:
On 26 August 2014 16:13, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
@@ -338,15 +338,20 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
while (SUCCEEDED(ret = IDirectXFileData_GetNextObject(object->dxfile_data, &data_object))) ... + new_children = HeapReAlloc(GetProcessHeap(), 0, object->children, + sizeof(*object->children) * (object->nb_children + 1)); While I suspect this is hardly the only thing wrong with xfile.c, it seems suboptimal to grow the array by 1 each time you go through the loop.
Yeah, it should start at some size greater than 1 (no idea about typical children count here though) and then grow exponentially. I guess that can be a separate patch, but I can also add it to this one and resend if preferred.
Actually, merging the two results in a bit less churn. So, this patch replaces the original one. I manually generated this patch via "git diff" (and kept the individual commits locally just in case), if this doesn't work right you can either commit the original one as-is or just leave it out.
participants (2)
-
Henri Verbeet -
Matteo Bruni