patch for unefficient memory reallocation in WMF driver

Dimitrie O. Paun dimi at intelliware.ca
Thu Aug 28 11:00:10 CDT 2003


On Thu, 28 Aug 2003 Dave_Belanger at cimmetry.com wrote:

+       if (len > physDev->allocatedSize){
+           if (!physDev->allocatedSize) {
+                   ERR("Unable to write record to unallocated memory\n");
+                       return FALSE;
+               }
+               /*expand size*/
+               physDev->allocatedSize = (size_t)(1.2* physDev->allocatedSize + rlen);
+               mh = HeapReAlloc( GetProcessHeap(), 0, physDev->mh, physDev->allocatedSize);
+               if (!mh) {
+                   ERR("Unable to Reallocate Heap memory\n");
+                       return FALSE;
+               }

I would suggest to not issue ERRs in such cases, as the API is designed to handle OOM
situations. I think it's enough to simply do:

    if (!physDev->allocatedSize) return FALSE;
...
    if (!mh) return FALSE;


We can not have ERRs all over the code where memory allocations fail, it would
clutter things way too much, and for almost no use.

-- 
Dimi.




More information about the wine-devel mailing list