Reply to post: Re: C / C++ compilers and libc could do this too

Rust in peace: Memory bugs in C and C++ code cause security issues so Microsoft is considering alternatives once again

Dagg

Re: C / C++ compilers and libc could do this too

But if I've allocated a and b and already verified that they are the same size, whats wrong with using strcpy?

The elephant in the middle of table table isn't when you first create this beautiful piece of software it is years down the track as it is maintained.

Some future developer changes the allocation of either a or b as they need to store a longer string. Your use of strcpy may several calls below where the change has been made and difficult to spot.

The single biggest cost with software is in the maintenance.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

SUBSCRIBE TO OUR WEEKLY TECH NEWSLETTER

Biting the hand that feeds IT © 1998–2019