PA_SetHandleSize

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_SetHandleSize (ahandle; newlen) char

ParameterTypeDescription
ahandlePA_HandleHandle to a valid memory block
newlenlongDesired new size
Function resultcharTrue (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.).


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next