From 415e7451bd6eccadcc69076610569c8182873c40 Mon Sep 17 00:00:00 2001 From: Tilen Majerle Date: Thu, 2 Jan 2020 20:53:45 +0100 Subject: [PATCH] Update docs --- docs/examples_src/example_minimal.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/examples_src/example_minimal.c b/docs/examples_src/example_minimal.c index 1dc7c02..565d405 100644 --- a/docs/examples_src/example_minimal.c +++ b/docs/examples_src/example_minimal.c @@ -1,7 +1,5 @@ #include "lwmem/lwmem.h" -void* ptr; - /* Create regions, address and length of regions */ static lwmem_region_t regions[] = { @@ -15,12 +13,17 @@ lwmem_region_t regions[] = { /* Assign regions for manager */ 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) { /* Allocation successful */ } -/* Later... */ /* Free allocated memory */ +/* Later... */ +/* Free allocated memory when not used */ lwmem_free(ptr); ptr = NULL; /* .. or */