Fergal Moran <[EMAIL PROTECTED]> writes:

> C/C++ do not implement dynamically resizable arrays.  However there are a
> lot of ways of achieving what you want to do.  Look into linked lists - any
> good C/C++ book should cover them - but be prepared for a late night!!

Linked lists would be a lot of overhead on an already memory-bound
heap. That's not to say that they don't have their place, but often an
array will be the better approach. 

I would look into putting the array into a MemHandle and using
MemHandleResize to resize the array. i.e.,

 MemHandle array_h;
 UInt16* array;
 UInt16 array_size;

 array_h = MemHandleNew(sizeof(UInt16) * array_size);
 /* Handle out of memory condition if array_h is NULL */
 array = MemHandleLock(array_h);

 for (i=0; i < array_size; ++i)
     array[i] = i * 2;

Later, to resize the array:

 MemHandleUnlock(array_h);
 err = MemHandleResize(array_h, newsize);
 /* Handlo out of memory condition if err != errNone */
 array = MemHandleLock(array_h);

-- 
Dave Carrigan ([EMAIL PROTECTED])            | YOW!  I can see 1987!!
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | PRESIDENT FORD is doing the
Seattle, WA, USA                            | REMAKE of "PAGAN LOVE
http://www.rudedog.org/                     | SONG"...he's playing ESTHER
                                            | WILLIAMS!!


-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to