IBM manual Managing Dynamically-Allocated Storage, ILE RPG for AS/400 Programmers Guide, name@

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 140
Image 140
name@

Managing Dynamically-Allocated Storage

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

*

 

 

 

 

 

 

 

 

*

* After: Now the names name@, name_len and next@ refer

*

*

 

to storage in the new element

 

 

*

*

 

 

 

 

 

 

 

 

*

* .-------------

.

 

.

--------------

.

*

*

 

.

------>

 

 

*

*

*

--->abc

name

*

*

*

3

name_len

 

*

*

*

----------

'

next

*

*

*

 

 

 

 

*

*

'-------------

'

 

'

--------------

'

*

*

 

 

 

 

 

 

 

 

*

* Now set the values of the new element.

 

 

*

* The next pointer is set to *NULL

to indicate that it is the￿

*

* end of the list.

 

 

 

 

 

*

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

C

 

 

EVAL

 

next@

= *NULL

 

 

 

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

* Save the length of the name (not

counting trailing blanks￿)

 

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

C

 

 

EVAL

 

name_len = %len(%trimr(name))

 

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

*Storage is allocated for the name and then set to the valu￿e of

*the name.

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

C

 

 

ALLOC

name_len

name@

 

 

C

 

 

EVAL

%SUBST(nameVal:1&gml.name_len) = name

 

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

*

 

 

 

 

 

 

 

 

*

* After:

 

 

 

 

 

 

 

*

*

 

 

 

 

 

 

 

 

*

* .-------------

.

 

.

--------------

.

 

*

*

 

.

------>

 

 

*

*

*---

>abc

name

*---

>newname

*

*

3

name_len

nn

 

*

*

*----------

'

next

*---

>

*

*

 

 

 

 

*

*

'-------------

'

 

'

--------------

'

 

*

*

-----------------------------------------------------------------

 

 

 

 

 

 

*

P AddName

 

E

 

 

 

 

 

 

 

 

 

 

 

 

Figure

52 (Part

3

of

5).

Memory Management - Build a Linked List of Names

116 ILE RPG for AS/400 Programmer's Guide

Page 140
Image 140
IBM manual Managing Dynamically-Allocated Storage, ILE RPG for AS/400 Programmers Guide, name@