From 4413b6a28f6d0be5bf2d76564432015b072e2f5b Mon Sep 17 00:00:00 2001 From: Wojtek Marczenko Date: Wed, 5 Jul 2023 15:37:07 +0200 Subject: [PATCH] Update C manual memory management example (#902) In C (as opposed to C++) the explicit cast from void* to int* is not required. It is also not idiomatic to do so in C code. Actual C codebase would use `malloc()` without the cast, and a C++ one (when not using abstractions) a `new int[n]` - both a bit cleaner and less verbose than this example. --- src/memory-management/manual.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/memory-management/manual.md b/src/memory-management/manual.md index 90767ec8..08db7cb8 100644 --- a/src/memory-management/manual.md +++ b/src/memory-management/manual.md @@ -10,7 +10,7 @@ You must call `free` on every pointer you allocate with `malloc`: ```c void foo(size_t n) { - int* int_array = (int*)malloc(n * sizeof(int)); + int* int_array = malloc(n * sizeof(int)); // // ... lots of code //