News for hackers. Stuff that matters.
Re:A simple C implementation to stream H.264 to browser usin... by slezyr on Thursday April 08, 2021 @08:31AM (#26737901)
> The alternative is that you could be using a language that uses highly optimized RAII types on the stack which are impossible to leak, and written by some of the best programmers in the world so you don’t have to juggle chainsaws.

Please, tell "the best programmers" that it's "impossible to leak" memory. Apparently they do not know this.

https://doc.rust-lang.org/book/ch15-06-reference-cycles.html

Re:A simple C implementation to stream H.264 to browser usin... by tediousdemise on Thursday April 08, 2021 @08:42AM (#26738002)
Thanks for sharing, I’m unfamiliar with the nuances of Rust’s implementation of RAII as I’m primarily a modern C++ developer. Modern C++ mostly guarantees against leaks since it encourages the stack as much possible.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...

Re:A simple C implementation to stream H.264 to browser usin... by allo37 on Thursday April 08, 2021 @08:53AM (#26738102)
It's the same deal as creating a circular references using `std::shared_ptr` in C++.
Re:A simple C implementation to stream H.264 to browser usin... by hctaw on Thursday April 08, 2021 @09:16AM (#26738294)
Ownership semantics in rust largely prevent circular references, so it's not the same deal
Re:A simple C implementation to stream H.264 to browser usin... by allo37 on Thursday April 08, 2021 @11:25AM (#26739959)
Sorry, I'm not a Rust pro, but from the docs about reference cycles linked above:

> We can see that Rust allows memory leaks by using Rc<T> and RefCell<T>: it’s possible to create references where items refer to each other in a cycle. This creates memory leaks because the reference count of each item in the cycle will never reach 0, and the values will never be dropped.

This sounds a lot like what happens when you create a circular reference with std::shared_ptr ?

Re:A simple C implementation to stream H.264 to browser usin... by hctaw on Thursday April 08, 2021 @01:08PM (#26741247)
Yes, but grep for `Rc::new()` in actual rust code bases compared to `shared_ptr` in C++. Interior mutability is cumbersome and not a natural pattern in practice.
Re:A simple C implementation to stream H.264 to browser usin... by steveklabnik on Thursday April 08, 2021 @12:39PM (#26740878)
Yes, it is the same thing.
Re:A simple C implementation to stream H.264 to browser usin... by orf on Thursday April 08, 2021 @08:40AM (#26737984)
Leak can mean different things. None of those types in the link are stack allocated, I think.