Passing RPointerArray as a function argument

Login to reply to this topic.
Mon, 2007-10-08 11:47
Joined: 2007-09-19
Forum posts: 71

hi i m using RPointerArray abc.

I am appending data to the same after allocating memory to Objects.
once i have all the data.. i pass abc to a function where i catch it as

void function(RPointerArray pqr)

Also once i come back from the function call i m deleting memory of the Objects one after another and then closing using Close() function..

But the program crashes ...
Is it that i cannot pass the RPointerArray Argument ?
or also is there a better way to do the same..

Thanks


Mon, 2007-10-08 12:21
Joined: 2006-09-18
Forum posts: 68
Re: Passing RPointerArray as a function argument

I think you must pass it as a reference, also RPointerArray is a template class.

void function(RPointerArray<TAny> &pqr)

Does it come up with a Panic(error) message?

Mon, 2007-10-08 12:42
Joined: 2007-09-19
Forum posts: 71
Re: Passing RPointerArray as a function argument

No actually the application just crashes...
so i tried using a exe this time using a RArray to check what is the exact problem

following is the code snippet....

void call(RArray* abc)
{
TInt i;
for(i=0;abc->Count();i++)
{

console->Printf(_L("%d"),(*abc)[i]);

}
//the application crashes with leave here i cannot get the code as the its a exe...

}

// do the example
LOCAL_C void doExampleL()
{

RArray a;
a.Append(10);
a.Append(20);
call(&a);
a.Reset();

a.Close();

console->Getch();
}

Is the you cannot pass the address and you have to pass a reference ?

Thanks..
Sohil

Mon, 2007-10-08 13:15
Joined: 2006-09-18
Forum posts: 68
Re: Passing RPointerArray as a function argument

No you can definitely pass an address, just in the previous definition you didn't pass a reference or a pointer, so it was copied. That should work as well, but is not a good idea. I think it does Panic, but you don't have the Panic codes enabled. Check http://newlc.com/Display-the-extended-panic-code-in.html and http://www.symbianresources.com/tutorials/general.php#os9 ->"ErrRd Installation Utility".

In any case if your code is exactly as in the post your problem is the for loop.

for(i=0;abc->Count();i++)
must be
for(i=0; i < abc->Count(); i++)

Mon, 2007-10-08 13:25
Joined: 2007-09-19
Forum posts: 71
Re: Passing RPointerArray as a function argument

oh ya..
i m sorry ..
it not the problem with passing the RPointerArray..
itss the problem with the loop...
thanks you very much for the help

Tue, 2007-10-09 11:44
Joined: 2006-09-18
Forum posts: 68
Re: Passing RPointerArray as a function argument

No problem sometimes you just can't see what's wrong with your own code. Eye-wink

Tue, 2007-10-09 11:49
Joined: 2007-09-19
Forum posts: 71
Re: Passing RPointerArray as a function argument

Smiling

  • Login to reply to this topic.