IBM AS/400 User Manual Page 142

  • Download
  • Add to my manuals
  • Print
  • Page
    / 489
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 141
Managing Dynamically-Allocated Storage
*-----------------------------------------------------------------*
* Free - release the storage used by the list *
*-----------------------------------------------------------------*
P Free B
D prv@ S *
*-----------------------------------------------------------------*
* Loop through the elements of the list until the next pointer is *
* *NULL, starting from the first real element in the list *
*-----------------------------------------------------------------*
C EVAL elem@ = %ADDR(first)
C EVAL elem@ = next@
C DOW elem@ <> *NULL
*-----------------------------------------------------------------*
* Free the storage for name *
*-----------------------------------------------------------------*
C DEALLOC name@
*-----------------------------------------------------------------*
* Save the pointer to current elem@
*-----------------------------------------------------------------*
C EVAL prv@ = elem@
*-----------------------------------------------------------------*
* Advance elem@ to the next element
*-----------------------------------------------------------------*
C EVAL elem@ = next@
*-----------------------------------------------------------------*
* Free the storage for the current element
*-----------------------------------------------------------------*
C DEALLOC prv@
C ENDDO
*-----------------------------------------------------------------*
* Ready for a new list:
*-----------------------------------------------------------------*
C EVAL elem@ = %ADDR(first)
P Free E
Figure 52 (Part 5 of 5). Memory Management - Build a Linked List of Names
Heap Storage Problems
Figure 53 on page 119 shows possible problems associated with the misuse of
heap storage.
118 ILE RPG for AS/400 Programmer's Guide
Page view 141
1 2 ... 137 138 139 140 141 142 143 144 145 146 147 ... 488 489

Comments to this Manuals

No comments