_GetHandSize( ), API-Bibliotheksroutine

Gibt die Anzahl der nutzbaren Bytes zurück, die mit dem angegebenen Speicherblockhandle hand verbunden sind.

unsigned long _GetHandSize(MHANDLE hand)
MHANDLE hand;            /* Handle of memory block. */

Hinweise

Die Anzahl nutzbarer Bytes ist immer größer oder gleich der Anzahl von Bytes, die zuletzt durch _AllocHand( ) oder durch Aufrufen von _SetHandSize( ) für dieses MHANDLE-Handle angefordert wurde.

Anmerkung   _GetHandSize( ) löst keine Reorganisation des Speichers aus.

Weitere Informationen zum Erstellen einer API-Bibliothek und ihrer Integration in Visual FoxPro finden Sie unter Zugreifen auf die Visual FoxPro-API.

Beispiel

Im folgenden Beispiel werden unterschiedlich große Speicherblöcke (von 1 bis 215) reserviert. Der von _GetHandSize( ) für diese Reservierung zurückgegebene Wert wird angezeigt. Beachten Sie, dass der von _GetHandSize( ) zurückgegebene Wert nur in manchen Fällen der von _AllocHand( ) angeforderten Größe entspricht. Normalerweise liegt der Wert etwas höher.

Visual FoxPro-Code

SET LIBRARY TO GETHANDS

C-Code

#include <pro_ext.h>

void putLong(long n)
{
   Value val;

   val.ev_type = 'I';
   val.ev_long = n;
   val.ev_width = 5;

   _PutValue(&val);
}

void FAR Example(ParamBlk FAR *parm)
{
   MHANDLE mh;
   unsigned int allocSize;

   for (allocSize = 1;; allocSize *= 2)
   {
      if ((mh = _AllocHand(allocSize)) == 0)
      {
         _Error(182);  // "Insufficient memory"
      }
      _PutStr("\n_AllocHand("); putLong(allocSize); _PutStr(")");
      _PutStr("\n_GetHandSize() ="); putLong(_GetHandSize(mh));
      _FreeHand(mh);
      if (allocSize == 32768)
      {
         break;
      }
   }
}

FoxInfo myFoxInfo[] = {
   {"ONLOAD", (FPFI) Example, CALLONLOAD, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

Siehe auch

_AllocHand( ), API-Bibliotheksroutine | _FreeHand( ), API-Bibliotheksroutine | _HandToPtr( ), API-Bibliotheksroutine | _HLock( ), API-Bibliotheksroutine | _HUnlock( ), API-Bibliotheksroutine | _MemAvail( ), API-Bibliotheksroutine | _SetHandSize( ), API-Bibliotheksroutine