From: Michael Mueller Date: 2003-03-11T22:10:44+09:00 Subject: Re: WIN32OLE: Passing an Array Well... at least now I know that it's not my fault ;-) Thanks for the hint - but I still have no idea how to bypass that prob. Does anyone have a suggestion? Michael pj wrote: >> my program crashes with a segmentation fault. >> I guess the problem lies in the arrays being passed to the method. I >> searched the web/usenet for any hints on how to pass an array to an ole >> object but found absolutely nothing. > > I am a clueless newbie in Ruby, knowing nearly less than nothing, but > arrays in COM (ie, OLE, ie, ActiveX, whichever name of the week you > like) are often passed as type SAFEARRAY. This is a structure holding > a dynamically allocated array (a traditional array of consecutive > bytes), but, and this is important, it is allocated using a task > allocator. That is, you cannot make one from your heap manager, unless > your heap manager is cooperating with the task allocator. > > There is a caveat: there are rules about memory ownership across COM > calls. If you are the caller, and you pass the ARRAY as a top-level IN > parameter only, then you own the memory, and the callee isn't allowed > to change it, and in this case, I believe you can get away with it not > being allocated from the task allocator.