[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vector passing
From: |
Marcus G. Daniels |
Subject: |
Re: Vector passing |
Date: |
18 Aug 2000 07:14:35 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "PJ" == Paul E Johnson <address@hidden> writes:
PJ> - (int *) vectorFunction
PJ> {
PJ> int avector[128];
PJ> blah blah;
PJ> avector;
PJ> //same as &avector[0] , the address of the first argument }
PJ> }
If you mean "return avector;", not "avector;", that won't work. It
won't work since the stack space for avector will disappear as soon as
the method returns, and the pointer will be invalid. It's also bad to
make avector static, since then pointer value (presumably strored
elsewhere) may become functionally invalid as soon as the method is
called again. You either should return an instance variable or
allocate new space (which has the down side of introducing a potential
memory leak).
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.