PA_SetHandleSize


version 2003


PA_SetHandleSize (ahandle; newlen) → char

Parameter Type Description
ahandle PA_Handle Handle to a valid memory block
newlen long Desired new size
Function result char True (1) if successful

Description

The routine PA_SetHandleSize shrinks or expands the size of the memory block led to by aHandle .

Handle must be a valid PA_Handle obtained from PA_NewHandle (or MacOS trap NewHandle).

A call to PA_GetLastError should always be done after using PA_SetHandleSize .

Example

Append data to an existing PA_Handle.

   short AppendDataToHandle(PA_Handle srce, char *toAppend, long size)
   {
      long      offset;
 
   // doesn't work with NULL pointers...
      if ( !  toAppend )
         return kERR_MyNullPointerError;
 
   // get the source handle size
      offset = PA_GetHandleSize(srce);
      if ( PA_GetLastError() == eER_NoErr )
      {
      // make room for the new data at the end of the handle
      // and copy data to it
         PA_SetHandleSize( srce, offset + size );
         if ( PA_GetLastError() == eER_NoErr )
            PA_MoveBlock( toAppend, *srce + offset, size );
      }
      return PA_GetLastError();
   }

See Also

PA_GetHandleSize .

Error Handling

Use PA_GetLastError to see if an error occurred (insufficient memory, not a valid PA_Handle , etc.).