From a070980af1171f7f7966ba5e8b2fb6ba529feb10 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Thu, 23 Apr 2020 18:04:22 +0200 Subject: [PATCH] added free_shared_memory method --- images.h | 1 + src/multithreading.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/images.h b/images.h index 6c16ae2..03390c8 100644 --- a/images.h +++ b/images.h @@ -49,6 +49,7 @@ int image_new_shared(int width, int height, Image* img); void image_destroy_shared(Image img); void* create_shared_memory(size_t size); +void free_shared_memory(void* ptr, size_t size); #include "src/images.c" #include "src/bmp-format.c" diff --git a/src/multithreading.c b/src/multithreading.c index 589f507..c5cca94 100644 --- a/src/multithreading.c +++ b/src/multithreading.c @@ -40,4 +40,8 @@ void* create_shared_memory(size_t size) { // The remaining parameters to `mmap()` are not important for this use case, // but the manpage for `mmap` explains their purpose. return mmap(NULL, size, protection, visibility, -1, 0); +} + +void free_shared_memory(void* ptr, size_t size) { + munmap(ptr, size); } \ No newline at end of file