Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Nice Chromium and clumsy memset

44 views
Skip to first unread message

Andrey Karpov

unread,
Jan 26, 2018, 3:36:11 AM1/26/18
to
We would like to suggest reading the series of articles dedicated to the recommendations on writing code of high quality using the examples of errors found in the Chromium project. This is the first part which will be devoted to the memset function.

Gentlemen, we must do something about the memset function in C++ programs! Rather, it is clear what we must do at once - we have to stop using it. I wrote the article "The most dangerous function in the C/C++ world" at the time. I think it is easy to guess that this article will be exactly about memset.

Continue: https://www.viva64.com/en/b/0553/

Öö Tiib

unread,
Jan 26, 2018, 5:52:39 AM1/26/18
to
On Friday, 26 January 2018 10:36:11 UTC+2, Andrey Karpov wrote:
> We would like to suggest reading the series of articles dedicated to the recommendations on writing code of high quality using the examples of errors found in the Chromium project. This is the first part which will be devoted to the memset function.

High quality recommendation suggests to use *something*.

For example either std::array<WebUChar,kTextLengthCap> or
std::basic_string<WebUChar> instead of those raw fixed or
allocated with new arrays in C++ ... and decades old idioms
'memset(p, 0, length * sizeof *p);' in C.

But your article fails even to tell relation between
constant 'kTextLengthCap' and variable 'text_length_cap'
as in

WebUChar text[kTextLengthCap];

and

memset(key_event->text, 0, text_length_cap);

"High quality" indeed. :D

cda...@gmail.com

unread,
Jan 26, 2018, 12:59:52 PM1/26/18
to
Mr. Rick's CAlive fixes such things.
0 new messages