logoalt Hacker News

kitdtoday at 6:15 AM1 replyview on HN

> I've also found that using those attributes inherently pushes your code to make ownership more explicit. I personally stopped being terrified of double-pointers and started using them for ownership transfers, which eliminates a large class of bugs.

This is very interesting. Do you have a practical example?


Replies

EPWN3Dtoday at 4:10 PM

Yeah here's a trivial one.

void *__free p = NULL;

func(&p); // func zeroes p to claim ownership

// end of scope, p is NULL, nothing happens // if func was not called, p is freed