RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

%REALLOC - Reallocate Storage Print E-mail
User Rating: / 0
PoorBest 
Written by Chamara Withanachchi   
%REALLOC(ptr:num)

%REALLOC changes the heap storage pointed to by the first parameter to be the length specified in the second parameter. The heap storage pointed to by the returned pointer has the same |value as the heap storage pointed to by ptr. If the new length is longer than the old length, the additional storage is |uninitialized.


The first parameter must be a basing pointer value. The second parameter must be a non-float numeric value with zero decimal places. The length specified must be between 1 and 16776704.


The function returns a pointer to the allocated storage. This may be the same as ptr or different. If the %REALLOC function is successful, the original pointer value specified in the first operand should not be used.



 /FREE
   // Allocate an area of 200 bytes
   pointer = %ALLOC(200);
   // Change the size of the area to 500 bytes
   pointer = %REALLOC(pointer:500);
   // Using two different pointers:
   pointer2 = %REALLOC(pointer1:500);
   pointer1 = *NULL;;
   // The returned value was assigned to
   // "pointer2", a different variable
   // from the input pointer "pointer1".
   // In this case, the value of "pointer1"
   // is no longer valid, so "pointer1" must
   // be set to *NULL to avoid using the
   // old value.
 /END-FREE
Next>