Christian Costa : d3dxof: Allocate subobjects at object creation time.

Alexandre Julliard julliard at winehq.org
Tue Dec 23 13:41:38 CST 2008


Module: wine
Branch: master
Commit: 23a3552d0dfaafb22cad8def66bbe46ef33e34a8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=23a3552d0dfaafb22cad8def66bbe46ef33e34a8

Author: Christian Costa <titan.costa at wanadoo.fr>
Date:   Tue Dec 23 11:56:27 2008 +0100

d3dxof: Allocate subobjects at object creation time.

---

 dlls/d3dxof/d3dxof.c         |   22 +++++++++++++++-------
 dlls/d3dxof/d3dxof_private.h |    4 ++--
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c
index 6ca6e98..6004ed6 100644
--- a/dlls/d3dxof/d3dxof.c
+++ b/dlls/d3dxof/d3dxof.c
@@ -2109,9 +2109,9 @@ static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional)
         TRACE("Found optional reference %s\n", (char*)buf->value);
         for (i = 0; i < buf->nb_pxo_globals; i++)
         {
-          for (j = 0; j < buf->pxo_globals[i*MAX_SUBOBJECTS].nb_subobjects; j++)
+          for (j = 0; j < (buf->pxo_globals[i])[0].nb_subobjects; j++)
           {
-            if (!strcmp(buf->pxo_globals[i*MAX_SUBOBJECTS+j].name, (char*)buf->value))
+            if (!strcmp((buf->pxo_globals[i])[j].name, (char*)buf->value))
               goto _exit;
           }
         }
@@ -2122,7 +2122,7 @@ _exit:
           return FALSE;
         }
         buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->cur_subobject++];
-        buf->pxo->childs[buf->pxo->nb_childs]->ptarget = &buf->pxo_globals[i*MAX_SUBOBJECTS+j];
+        buf->pxo->childs[buf->pxo->nb_childs]->ptarget = &(buf->pxo_globals[i])[j];
         buf->pxo->nb_childs++;
       }
       else if (check_TOKEN(buf) == TOKEN_NAME)
@@ -2237,13 +2237,20 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
   if (FAILED(hr))
     return hr;
 
-  This->buf.pxo_globals = &This->xobjects[0][0];
+  This->buf.pxo_globals = This->xobjects;
   This->buf.nb_pxo_globals = This->nb_xobjects;
-  This->buf.pxo_tab = &This->xobjects[This->nb_xobjects][0];
-  This->buf.cur_subobject = 0;
-  This->buf.pxo = &This->buf.pxo_tab[This->buf.cur_subobject++];
+  This->buf.cur_subobject = 1;
   This->buf.level = 0;
 
+  This->buf.pxo_tab = HeapAlloc(GetProcessHeap(), 0, sizeof(xobject)*MAX_SUBOBJECTS);
+  if (!This->buf.pxo_tab)
+  {
+    ERR("Out of memory\n");
+    hr = DXFILEERR_BADALLOC;
+    goto error;
+  }
+  This->buf.pxo = This->xobjects[This->nb_xobjects] = This->buf.pxo_tab;
+
   pdata = HeapAlloc(GetProcessHeap(), 0, MAX_DATA_SIZE);
   if (!pdata)
   {
@@ -2291,6 +2298,7 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
 
 error:
 
+  HeapFree(GetProcessHeap(), 0, This->buf.pxo_tab);
   HeapFree(GetProcessHeap(), 0, pdata);
   HeapFree(GetProcessHeap(), 0, pstrings);
 
diff --git a/dlls/d3dxof/d3dxof_private.h b/dlls/d3dxof/d3dxof_private.h
index 7cb82cd..d7cd9c8 100644
--- a/dlls/d3dxof/d3dxof_private.h
+++ b/dlls/d3dxof/d3dxof_private.h
@@ -130,7 +130,7 @@ typedef struct {
   LPBYTE cur_pdata;
   LPBYTE cur_pstrings;
   BYTE value[100];
-  xobject* pxo_globals;
+  xobject** pxo_globals;
   ULONG nb_pxo_globals;
   xobject* pxo_tab;
   IDirectXFileImpl* pdxf;
@@ -149,7 +149,7 @@ typedef struct {
     parse_buffer buf;
     IDirectXFileImpl* pDirectXFile;
     ULONG nb_xobjects;
-    xobject xobjects[MAX_OBJECTS][MAX_SUBOBJECTS];
+    xobject* xobjects[MAX_OBJECTS];
 } IDirectXFileEnumObjectImpl;
 
 typedef struct {




More information about the wine-cvs mailing list