× 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: problems with ALLOC and REALLOC
  • From: bellis@xxxxxxxxxxxx
  • Date: Thu, 20 Jan 2000 12:58:51 -0600



We attempted to use ALLOC and REALLOC opcodes on a array declared with a DIM of
100 elements, so that it could be resized as needed.
The array was declared with a basing pointer so the memory for the array would
not be allocated until the ALLOC opcode was used.
When the array was allocated with a size less than the size for the maximum
number of element using the ALLOC opcode. The full amount of memory for the
array was allocated at 100 elements instead of the specified size.  We were able
to assign values to elements outside of the range that was allocated etc..
When following the code below the first time the value for arySize = 10
(2bytes * 5)
When following the code below the second  time the value for arySize = 20
Also, since the whole array was allocated, REALLOC had no effect.
Any thoughts on why ALLOC/REALLOC would not work as indicated?
We are at V4R3 O/S level.

Thanks in advance.
Brian Ellis



 *resizable array for WMS order types
DpOrdTypAry      S               *
D ordTypAry       S              3P 0 DIM(100)
D                                           based(pOrdTypAry)
DarySize             S       10i  0
D aryCntr         S             10I 0 INZ(1)


C    AllocAry      BegSr

C                  Eval      arySize = %size(OrdTypAry) * 5
C                  Alloc     arySize       pOrdTypAry


C    ResizeAry     BegSr

C                  Eval      arySize = arySize + (%size(ordTypAry) *  5)
C                  ReAlloc   arySize       pOrdTypAry





+---
| 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.