libv4l2cpp icon indicating copy to clipboard operation
libv4l2cpp copied to clipboard

don't use memset() for initialization in C++

Open AndreiCherniaev opened this issue 2 years ago • 2 comments

more details https://stackoverflow.com/questions/1998752/memset-or-value-initialization-to-zero-out-a-struct

AndreiCherniaev avatar Mar 24 '23 05:03 AndreiCherniaev

Hi,

The buffer structure is a POD, there is no virtual.

Best Regards, Michel.

mpromonet avatar Mar 25 '23 10:03 mpromonet

Hi,

The buffer structure is a POD, there is no virtual.

Best Regards, Michel.

  1. POD means Plain old data? Yes, I agree. But why you use memset ()? You can. But it is bad C++ style. Isn't it? ={} is universal must have for data initiation in C++.
  2. What about caps?

AndreiCherniaev avatar Mar 25 '23 15:03 AndreiCherniaev

@mpromonet please approve commit!

AndreiCherniaev avatar Aug 18 '24 07:08 AndreiCherniaev

Hi @AndreiCherniaev Thanks, but your modifications doesnot bring improvement. Best Regards Michel

mpromonet avatar Aug 19 '24 17:08 mpromonet

my commit brings C++ style to avoid potential bugs with memory. Don't use memset() if you can make another way... memset() in top of the most dangerous functions...

AndreiCherniaev avatar Aug 20 '24 08:08 AndreiCherniaev