|
|
Subscribe / Log in / New account

Poettering: Revisiting how we put together Linux systems

Poettering: Revisiting how we put together Linux systems

Posted Sep 3, 2014 9:50 UTC (Wed) by dgm (subscriber, #49227)
In reply to: Poettering: Revisiting how we put together Linux systems by zlynx
Parent article: Poettering: Revisiting how we put together Linux systems

> shared_ptr implemented in pure C

I would be interested in seeing some example of this. Really. I'm tempted to say it's simply impossible, because C lacks destructors.

Unless... you mean plain old reference counting, which is rather trivial and easy to understand. Much easier than, for instance, the subtle differences between all the smart pointer templates in the STL. And you can add BOOST and/or Qt or Microsoft's for extra fun. Easy-peasy.


to post comments

Poettering: Revisiting how we put together Linux systems

Posted Sep 3, 2014 18:26 UTC (Wed) by Trelane (subscriber, #56877) [Link]

The nearest I know of its the gcc/clang extension to add function to be automatically called when an automatic various goes out of scope (is an Attribute: cleanup)

Poettering: Revisiting how we put together Linux systems

Posted Sep 3, 2014 18:52 UTC (Wed) by zlynx (guest, #2285) [Link] (2 responses)

I meant plain old reference counting. I've seen it done a lot in script language interpreters. It's done manually, it's prone to mistakes and is buggy as hell.

Poettering: Revisiting how we put together Linux systems

Posted Sep 5, 2014 8:56 UTC (Fri) by quotemstr (subscriber, #45331) [Link] (1 responses)

> It's done manually, it's prone to mistakes and is buggy as hell.

I don't agree that manual reference counting is particularly hard. Practically the entire world does it, and it works fine.

I've read my share of interpreters. Reference counting isn't particularly hard, although you want to use tracing GC if you don't want your users ripping their hair out over cycles.

I've seen far more problems with shared_ptr.

Poettering: Revisiting how we put together Linux systems

Posted Sep 5, 2014 18:13 UTC (Fri) by zlynx (guest, #2285) [Link]

Ah then, tell me if adding a value to a Python list increments the ref count or not. What about if you add it to a list?

Poettering: Revisiting how we put together Linux systems

Posted Sep 4, 2014 5:25 UTC (Thu) by jra (subscriber, #55261) [Link] (2 responses)

Look at the talloc library we use in Samba. It's written in C. It has destructors. Helps keep the Samba C code sane :-).

Poettering: Revisiting how we put together Linux systems

Posted Sep 23, 2014 13:05 UTC (Tue) by dgm (subscriber, #49227) [Link] (1 responses)

I'm looking at it right now and, the only thing I can think of is: Clever. Very clever.

Thanks for the pointer (pun intended).

Poettering: Revisiting how we put together Linux systems

Posted Sep 23, 2014 16:56 UTC (Tue) by rahulsundaram (subscriber, #21946) [Link]


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds