diff --git a/.zk/notebook.db b/.zk/notebook.db index b2af398..3f4536b 100644 Binary files a/.zk/notebook.db and b/.zk/notebook.db differ diff --git a/zk/Heap_memory.md b/zk/Heap_memory.md index 7281185..4a2f5c3 100644 --- a/zk/Heap_memory.md +++ b/zk/Heap_memory.md @@ -1,7 +1,7 @@ --- id: 18bl title: Heap_memory -tags: [memory] +tags: [memory, C] created: Saturday, April 20, 2024 --- @@ -20,4 +20,15 @@ _garbage collection_. In a language like C, this is the explicit concern of the programmer and is not abstracted away. Failure to properly manage garbage collection is what causes [[Memory_leaks]]. +Here is an example of managing heap memory allocation in C: + +```c +void * data; +data = malloc(512) +``` + +The first line assigns a special _pointer_ variable (indicated by `void *` +rather than `int` or `str`) . This is a variable only holds a memory address. +The `malloc` method assigns 512 bytes to the `data` variable. + ## Related notes