SYNTAX
void *hal_malloc(long int size)
ARGUMENTE
- Größe
-
Gibt die Größe des Blocks in Bytes an.
BESCHREIBUNG
hal_malloc allocates a block of memory from the main HAL shared memory area. It should be used by all components to allocate memory for HAL pins and parameters. It allocates ‘size’ bytes, and returns a pointer to the allocated space, or NULL (0) on error. The returned pointer will be properly aligned for any type HAL supports. A component should allocate during initialization all the memory it needs.
Der Allokator ist sehr einfach, und es gibt kein ‘free’. Der gesamte gemeinsame HAL-Speicherbereich wird freigegeben, wenn die letzte Komponente hal_exit aufruft. Das bedeutet, wenn Sie ständig eine Komponente installieren und entfernen, während andere Komponenten vorhanden sind, wird der gemeinsam genutzte Speicher irgendwann voll sein, und eine Installation wird fehlschlagen. Wenn Sie alle Komponenten vollständig entfernen, wird der Speicher freigegeben und Sie können neu beginnen.
RETURN VALUE
Ein Zeiger auf den zugewiesenen Speicherplatz, der für jede von HAL unterstützte Variable korrekt ausgerichtet ist. Gibt im Fehlerfall NULL zurück.