Bull DPX/20 Podręcznik Użytkownika Strona 115

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 424
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 114
SOM Kernel Reference 1-103
Example
#include <animal.h>
main()
{
void *myAnimalCluster;
Animal animals[5];
SOMClass animalClass;
int animalSize, i;
animalClass =
AnimalNewClass(Animal_MajorVersion,Animal_MinorVersion);
animalSize = _somGetInstanceSize (animalClass);
/* Round up to double–word multiple */
animalSize = ((animalSize+3)/4)*4;
/*
* Next line allocates room for 5 objects
* in a &odq.cluster” with a single memory-
* allocation operation.
*/
myAnimalCluster = SOMMalloc (5*animalSize);
/*
* The for-loop that follows creates 5 initialized
* Animal instances within the memory cluster.
*/
for (i=0; i<5; i++)
animals[i] =
_somRenew(animalClass, myAnimalCluster+(i*animalSize));
/* Uninitialize the animals explicitly: */
for (i=0; i<5; i++)
_somUninit(animals[i]);
/*
* Finally, the next line frees all 5 animals
* with one operation.
*/
SOMFree (myAnimalCluster);
}
Original Class
SOMClass
Related Information
Methods: somGetInstanceSize, somInit, somNew
Przeglądanie stron 114
1 2 ... 110 111 112 113 114 115 116 117 118 119 120 ... 423 424

Komentarze do niniejszej Instrukcji

Brak uwag