"Jimi Malcolm" <[EMAIL PROTECTED]> wrote:
>Here's the general idea in code.  It's not my actual code but I didn't want
>to waste anyone's time with the details which are probably unneccessary for
>the question at hand.
>
><<<CODE>>>
>void foo(ObjectType *oA);    // Prototype
>    ...
>void foo(ObjectType *oA) {
>    ...
>}

The pointer oA is local to the function Foo.  Any changes you make
to the value of oA will be lost when you exit Foo.  The only way to
change a pointer from the calling scope is to pass the address of the
pointer itself from the calling scope:

  void foo(ObjectType **p)
  {
    ObjectType *oA = *p;
    ...work with oA...
    ++(*p);
  }

>ObjectType oTemp;
>    ...
>// Have oTemp be the first object in memory in a series of ObjectType
>objects.

oTemp needs to be an array if you're going to walk through
multiple ObjectType items stored contiguously in memory:

  ObjectType oTemp[NUMOBJECTTYPES];

>    ...
>for (i = 0; i < max; i++) {
>    foo(&oTemp);    // Each time it moves to the next one in the series
>}

Since you want to pass in a pointer from the calling scope that's
modified in Foo, you need to declare a variable in the calling scope:

  ObjectType *p = oTemp;        // same as &oTemp[0]
  for (i = 0; i < max; i++) {
    foo(&p);    // Each time it moves to the next one in the series

Having said all that, I'm not sure why you'd want to do this instead
of just doing the incrementing on the calling side:

  void foo(ObjectType *oA)
  {
     ...work with oA...
  }

  for (i = 0; i < max; ++i)
    foo(&oTemp[i]);

Do you really have a contiguous array of objects on the calling side?

-- 
    -M-                                              [EMAIL PROTECTED]

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to