* ext/win32ole/win32ole.c (ole_event_free, EVENTSINK_Destructor,

fev_initialize): remove the connection ole_event_free and 
  EVENTSINK_Destructor.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2007-08-25 14:01:08 +00:00
parent 5ba27573a0
commit 890eb07370
2 changed files with 15 additions and 31 deletions

View File

@ -1,3 +1,9 @@
Sat Aug 25 22:50:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_event_free, EVENTSINK_Destructor,
fev_initialize): remove the connection ole_event_free and
EVENTSINK_Destructor.
Sat Aug 25 17:52:06 2007 Koichi Sasada <ko1@atdot.net> Sat Aug 25 17:52:06 2007 Koichi Sasada <ko1@atdot.net>
* string.c, include/ruby/intern.h: export rb_str_length(). * string.c, include/ruby/intern.h: export rb_str_length().

View File

@ -116,7 +116,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE) #define WC2VSTR(x) ole_wc2vstr((x), TRUE)
#define WIN32OLE_VERSION "1.0.3" #define WIN32OLE_VERSION "1.0.4"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@ -173,7 +173,6 @@ typedef struct tagIEVENTSINKOBJ {
DWORD m_dwCookie; DWORD m_dwCookie;
IConnectionPoint *pConnectionPoint; IConnectionPoint *pConnectionPoint;
ITypeInfo *pTypeInfo; ITypeInfo *pTypeInfo;
int *ptr_freed;
}IEVENTSINKOBJ, *PIEVENTSINKOBJ; }IEVENTSINKOBJ, *PIEVENTSINKOBJ;
VALUE cWIN32OLE; VALUE cWIN32OLE;
@ -230,7 +229,6 @@ struct oleparamdata {
}; };
struct oleeventdata { struct oleeventdata {
IEVENTSINKOBJ *pEvent;
int freed; int freed;
}; };
@ -7139,7 +7137,6 @@ EVENTSINK_Constructor() {
pEv->m_dwCookie = 0; pEv->m_dwCookie = 0;
pEv->pConnectionPoint = NULL; pEv->pConnectionPoint = NULL;
pEv->pTypeInfo = NULL; pEv->pTypeInfo = NULL;
pEv->ptr_freed = NULL;
return pEv; return pEv;
} }
@ -7147,7 +7144,6 @@ void EVENTSINK_Destructor(
PIEVENTSINKOBJ pEVObj PIEVENTSINKOBJ pEVObj
) { ) {
if(pEVObj != NULL) { if(pEVObj != NULL) {
*(pEVObj->ptr_freed) = 1;
free(pEVObj); free(pEVObj);
pEVObj = NULL; pEVObj = NULL;
} }
@ -7361,25 +7357,7 @@ ole_event_free(struct oleeventdata *poleev)
{ {
ITypeInfo *pti = NULL; ITypeInfo *pti = NULL;
IConnectionPoint *pcp = NULL; IConnectionPoint *pcp = NULL;
free(poleev);
if (poleev->freed == 1) {
/*
* this return create memory leak.
* but poleev->pEvent->pConnectionPoint shoul'd not be freed
* until poleev->freed == 0.
*/
return;
}
if(poleev->pEvent) {
pti = poleev->pEvent->pTypeInfo;
if(pti) OLE_RELEASE(pti);
pcp = poleev->pEvent->pConnectionPoint;
if(pcp) {
pcp->lpVtbl->Unadvise(pcp, poleev->pEvent->m_dwCookie);
OLE_RELEASE(pcp);
}
free(poleev);
}
} }
static VALUE static VALUE
@ -7388,7 +7366,9 @@ fev_s_allocate(VALUE klass)
VALUE obj; VALUE obj;
struct oleeventdata *poleev; struct oleeventdata *poleev;
obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev); obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev);
/*
poleev->pEvent = NULL; poleev->pEvent = NULL;
*/
return obj; return obj;
} }
@ -7471,14 +7451,12 @@ fev_initialize(int argc, VALUE *argv, VALUE self)
} }
Data_Get_Struct(self, struct oleeventdata, poleev); Data_Get_Struct(self, struct oleeventdata, poleev);
poleev->pEvent = pIEV; pIEV->m_event_id
poleev->pEvent->m_event_id
= NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0)); = NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0));
poleev->pEvent->pConnectionPoint = pConnectionPoint; pIEV->pConnectionPoint = pConnectionPoint;
poleev->pEvent->pTypeInfo = pTypeInfo; pIEV->pTypeInfo = pTypeInfo;
poleev->pEvent->m_dwCookie = dwCookie; pIEV->m_dwCookie = dwCookie;
poleev->freed = 0;
poleev->pEvent->ptr_freed = &(poleev->freed);
rb_ary_push(ary_ole_event, self); rb_ary_push(ary_ole_event, self);
events = rb_ary_new(); events = rb_ary_new();