Jacek Caban : oleaut32: Added warn+heap support for cached BSTRs.
Alexandre Julliard
julliard at winehq.org
Wed May 2 14:30:03 CDT 2012
Module: wine
Branch: master
Commit: 2217e42c9d351a250fb27550d2262218721ebac1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2217e42c9d351a250fb27550d2262218721ebac1
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 2 16:25:11 2012 +0200
oleaut32: Added warn+heap support for cached BSTRs.
---
dlls/oleaut32/oleaut.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/dlls/oleaut32/oleaut.c b/dlls/oleaut32/oleaut.c
index b84fdc4..97d1b96 100644
--- a/dlls/oleaut32/oleaut.c
+++ b/dlls/oleaut32/oleaut.c
@@ -41,6 +41,7 @@
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
+WINE_DECLARE_DEBUG_CHANNEL(heap);
/******************************************************************************
* BSTR {OLEAUT32}
@@ -97,6 +98,10 @@ typedef struct {
#define BUCKET_SIZE 16
+#define ARENA_INUSE_FILLER 0x55
+#define ARENA_TAIL_FILLER 0xab
+#define ARENA_FREE_FILLER 0xfeeefeee
+
static bstr_cache_entry_t bstr_cache[0x10000/BUCKET_SIZE];
static inline size_t bstr_alloc_size(size_t size)
@@ -140,6 +145,14 @@ static bstr_t *alloc_bstr(size_t size)
LeaveCriticalSection(&cs_bstr_cache);
if(cache_entry) {
+ if(WARN_ON(heap)) {
+ size_t tail;
+
+ memset(ret, ARENA_INUSE_FILLER, FIELD_OFFSET(bstr_t, u.ptr[size+sizeof(WCHAR)]));
+ tail = bstr_alloc_size(size) - FIELD_OFFSET(bstr_t, u.ptr[size+sizeof(WCHAR)]);
+ if(tail)
+ memset(ret->u.ptr+size+sizeof(WCHAR), ARENA_TAIL_FILLER, tail);
+ }
ret->size = size;
return ret;
}
@@ -250,6 +263,13 @@ void WINAPI SysFreeString(BSTR str)
cache_entry->buf[(cache_entry->head+cache_entry->cnt)%((sizeof(cache_entry->buf)/sizeof(*cache_entry->buf)))] = bstr;
cache_entry->cnt++;
+ if(WARN_ON(heap)) {
+ unsigned i, n = bstr_alloc_size(bstr->size) / sizeof(DWORD) - 1;
+ bstr->size = ARENA_FREE_FILLER;
+ for(i=0; i<n; i++)
+ bstr->u.dwptr[i] = ARENA_FREE_FILLER;
+ }
+
LeaveCriticalSection(&cs_bstr_cache);
return;
}
More information about the wine-cvs
mailing list