[HN Gopher] Fixing a memory leak of xmlEntityPtr in librsvg
___________________________________________________________________
Fixing a memory leak of xmlEntityPtr in librsvg
Author : JNRowe
Score : 17 points
Date : 2024-06-22 12:28 UTC (1 days ago)
(HTM) web link (viruta.org)
(TXT) w3m dump (viruta.org)
| akira2501 wrote:
| Tangentially.. this is one of the things I don't like about a lot
| "newer" languages, like Rust and Zig. They seem to really love
| adding these single character sigils to the language that
| drastically change the meaning of a line of code or maybe an
| entire function.
|
| As I get older my eyes strain more and all of this power packed
| into a single character really just puts me off. It seems like a
| strategy to emphasize writing code quickly rather than correctly,
| which is odd, given that this is opposite to the value
| proposition these languages purport to bring.
| filmor wrote:
| The ? is not really the issue here. Rust is similar to C++ in
| that it encourages implicit resource management using scopes,
| so if you have resources that have to be free'd, you have to
| implement Drop somewhere.
|
| The code would have looked just as correct and would have been
| just as wrong with the "old" non-sigil `try!(...)` syntax.
| akira2501 wrote:
| > The ? is not really the issue here.
|
| Based upon the way the code was written, it was, at least in
| the mind of the author. They forgot they could exit scope
| there. They clearly didn't _intend_ for that outcome, but
| ended up with it anyways, possibly out of habit, and possibly
| because a single impactful sigil like that is easy to miss in
| review.
|
| I get that technically it didn't cause the memory leak.. but
| just look at the way that was written initially... it
| obviously led to it _within_ that particular structure.
| nemetroid wrote:
| > They forgot they could exit scope there.
|
| Their mistake was writing resource management code that
| requires manually thinking about where they might exit
| scope.
___________________________________________________________________
(page generated 2024-06-23 23:01 UTC)