this post was submitted on 08 Jun 2026
550 points (94.2% liked)

Programmer Humor

31959 readers
1542 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] Sylvartas@lemmy.dbzer0.com 10 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Most of the time you pass by reference for more outputs, or by const ref to avoid copying a big-ass data structure (which is not always straightforward, with structures smaller than a pointer, which are pretty big in 64 bits architecture, you lose more to the ref overhead than to the copy IIRC)

[โ€“] DahGangalang@infosec.pub 4 points 2 weeks ago

Another reason I commonly see: to change the structure / "main pointer" to a data structure (esp during freeing and cleanup).