Update docs

This commit is contained in:
Tilen Majerle 2020-01-02 20:53:45 +01:00
parent 64fd18a164
commit 415e7451bd

View File

@ -1,7 +1,5 @@
#include "lwmem/lwmem.h" #include "lwmem/lwmem.h"
void* ptr;
/* Create regions, address and length of regions */ /* Create regions, address and length of regions */
static static
lwmem_region_t regions[] = { lwmem_region_t regions[] = {
@ -15,12 +13,17 @@ lwmem_region_t regions[] = {
/* Assign regions for manager */ /* Assign regions for manager */
lwmem_assignmem(regions, sizeof(regions) / sizeof(regions[0])); lwmem_assignmem(regions, sizeof(regions) / sizeof(regions[0]));
ptr = lwmem_malloc(8); /* Allocate 8 bytes of memory */ /* Usage in program... */
void* ptr;
/* Allocate 8 bytes of memory */
ptr = lwmem_malloc(8);
if (ptr != NULL) { if (ptr != NULL) {
/* Allocation successful */ /* Allocation successful */
} }
/* Later... */ /* Free allocated memory */ /* Later... */
/* Free allocated memory when not used */
lwmem_free(ptr); lwmem_free(ptr);
ptr = NULL; ptr = NULL;
/* .. or */ /* .. or */