Modernization Hub

Dereference

Enhanced Definition

In the context of mainframe programming, **dereferencing** is the operation of accessing the data value stored at the memory address indicated by a pointer variable. It effectively "follows" the pointer to retrieve the actual data rather than the memory address itself, enabling indirect access to data. In the context of mainframe programming, particularly in languages like C/C++ and PL/I on z/OS, **dereferencing** is the operation of accessing the value or data stored at the memory address pointed to by a pointer variable. It effectively "follows" the pointer to retrieve the actual data it references, rather than the address itself.

Key Characteristics

    • Operates on a pointer variable (e.g., POINTER in PL/I, * in C) to retrieve the content of the memory location it points to.
    • Essential for indirect data access, allowing programs to manipulate data whose location is determined at runtime or is not directly named.
    • Can lead to program abends (e.g., 0C4 abend, ASRA in CICS) if the pointer contains an invalid or unallocated memory address, or if it's a NULL pointer.
    • Often used in conjunction with dynamic storage allocation (e.g., GETMAIN in z/OS Assembler, ALLOCATE in PL/I, malloc in C) where the memory address is returned as a pointer.
    • In PL/I, dereferencing is often implicit when a BASED variable is associated with a POINTER variable, allowing direct access to the data structure defined by the BASED variable.

Use Cases

    • Accessing dynamically allocated storage: After using GETMAIN (Assembler) or ALLOCATE (PL/I) to obtain memory, a pointer to that storage is returned, which must be dereferenced to store or retrieve data within the newly acquired memory block.
    • Traversing complex data structures: Navigating linked lists, trees, or other structures where elements contain pointers to subsequent elements (e.g., in user-defined control blocks or application-specific data structures).
    • Working with system control blocks: In z/OS system programming, pointers are extensively used to locate and access various system control blocks (e.g., TCB, ASCB, DEB) whose addresses are often found in other control blocks or system areas.
    • Passing parameters by reference (indirectly): While COBOL typically uses BY REFERENCE, languages like C or PL/I can pass pointers to data, and the called routine then dereferences these pointers to access and modify the original data in the caller's storage.

Related Concepts

Dereferencing is inextricably linked to pointers, as it is the fundamental operation for using them to access data. It complements memory management concepts like GETMAIN/FREEMAIN (z/OS services) or ALLOCATE/FREE (PL/I) by providing the means to access the storage acquired. In PL/I, it's closely associated with BASED variables, which provide a

Related Vendors

Tone Software

14 products

IBM

646 products

Trax Softworks

3 products

Related Categories

Operating System

154 products

Security

144 products

REXX

23 products

Automation

222 products