× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: RPG400-L Digest V3 #153
  • From: "Sims, Ken" <KSIMS@xxxxxxxxxxxxxxxx>
  • Date: Mon, 16 Apr 2001 17:52:27 -0400

Hi James -

>alloc  sizeof(strdata)         ptr
>
>and get the first occurence of strdata.  Then I ought to be able to
>
>alloc  sizeof(strdata)         ptr
>
>and get another occurence of strdata, or the second occurence.

Unless you save the value of the pointer, when you do the second ALLOC, you
will lose the pointer to the first memory area.  If you want to use separate
ALLOCs, then you need an array of pointers, which gets you right back to
where you started from.

What you want to do is ALLOC a memory area, then REALLOC to increase the
size of the memory area.  This keeps all of your occurrences contiguous.
Then all you need is two pointers, one to point to the start of memory and
one to point to the occurrence that you want to work with.  (You can
actually do it with one, but if you are not extremely careful, you will lose
your place.)  You use a single-occurrence data structure based on the second
pointer.  A little pointer arithmetic gets you to whatever occurrence you
want, without bounds.

This way you can have as many occurrences as you can fit in whatever the
maximum amount of memory is that can be ALLOCated/REALLOCated in one chunk,
which happens to be 16MB.

Ken
Southern Wine and Spirits of Nevada, Inc.
Opinions expressed are my own and do not necessarily represent the views of
my employer or anyone in their right mind.

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.