There has been quite a ruckus the past few days on DLL and in this post I want to add a different point of view: why you should be using Arrays instea

*ฅ^•ﻌ•^ฅ* ✨✨  HWisnu's blog  ✨✨ о ฅ^•ﻌ•^ฅ

submited by
Style Pass
2025-01-22 21:30:08

There has been quite a ruckus the past few days on DLL and in this post I want to add a different point of view: why you should be using Arrays instead of Pointers when writing DLL.

I'm going to provide the code using diff in Neovim..at first it will look noisy visually but after awhile you'll see it helps on understanding the difference between the two version: using Pointers vs using Arrays.

--Note--: on PC you need to "Open image in new tab" then double click the image for it to zoom-in. On mobile phone you can just pinch-zoom to enlarge the image.

Nothing particularly interesting / worth noting in the second image. Don't forget to free the memory if you're using pointers!

So there you go, writing DLL using Arrays is both faster and safer. Why safer? You need to read up on why working with raw pointers are dangerous and prone to memory errors.

I'm keeping this post short and concise as I want to point out or even spread the word to normalize the use of arrays instead of pointers in C programming when you can.

Leave a Comment
Related Posts