/srv/irclogs.ubuntu.com/2009/01/25/#upstart.txt

=== sadmac_ is now known as sadmac
Keybukvoid foo() {17:46
Keybuk    nih_local char *foo;17:46
Keybuk    foo = nih_strdup (NULL, foo);17:46
Keybuk}17:46
Keybuk\o/17:46
* Keybuk is a genius17:46
Keybukthat pointer will be automatically freed when the function returns ;)17:46
ion_keybuk: Ooh. How does it work? Using some gcc extension, i presume.19:20
Keybukion_: yup ;)19:21
Keybukonly works because of the new allocator, of course19:22
Keybukthe great thing is, that this works:19:22
Keybukvoid foo() {19:22
Keybuk     nih_local char *foo;19:22
Keybuk     foo = nih_strdup (NULL, foo);19:22
Keybuk     pass_to_some_func (foo);19:22
Keybuk}19:22
Keybukif pass_to_some_func() references foo, it won't be freed :-)19:22
ion_Neat19:22
Keybukbut if it doesn't, foo is freed ;-)19:23
ion_Heh, if i type “? libnih” to the address bar, Firefox opens http://fi.wikipedia.org/wiki/Gottfried_Leibniz19:23
ion_libnih’s trunk doesn’t seem to contain nih_local. What is it defined as?19:25
KeybukI haven't pushed it yet19:29
Keybukuses __attribute__((cleanup))19:30
Keybukwhich calls a function and passes a pointer to the variable when it goes out of scope19:30
ion_Alright19:31
KeybukI thought about just having something like19:33
Keybuk  nih_local_context ctx;19:33
Keybukwhere you'd pass that in instead of NULL for the given block19:33
Keybukbut decided that "nih_local type *var;" was nicer ;)19:33
ion_Yeah19:33
sadmacKeybuk: what else is on the list of nih improvements?19:35
Keybukd-bus properties19:36
Keybuksignal handling, etc.19:36
Keybukbetter main loop19:36
sadmacKeybuk: do you have asynchronous method calls for dbus? That'd help for some initctl stuff19:37
Keybukthat's on the todo list19:37
sadmacis there enough on launchpad for me to pitch in?19:38
Keybukfor the d-bus stuff?19:40
Keybukit hasn't changed in months19:40
Keybukand I believe I suggested it as something for you to do months ago, and gave you notes ;-)19:40
sadmacKeybuk: I assume the new memory management would want to be underneath all of it though.19:41
KeybukI don't think the D-Bus functions use anything that has changed19:42
Keybukonly functions that call nih_alloc_reparent are affected19:42
Keybukotherwise the API is entirely compatible19:42
keesjis nih used for other projects?20:50
sadmackeesj: no, and its really not set up to be right now20:55
sadmacit operates more as a code patch than an actual library20:55
sadmacwe only barely get away with that because upstart is the only consumer20:56
sadmac(and its due to change soon)20:56
ion_My idlemeter uses libnih. :-P20:59
Keybukmy train set controller uses libnih too ;)21:00
Keybukit wasn't even originally written for upstart (which is why upstart uses less than half of it)21:00
Keybukit was originally written for dpkg2 ;-)21:00
Keybukkeesj: if you treat it as a library that changes API on a whim, it's quite usable21:01
Keybukie. don't bzr update libnih in your tree unless you've read the coming changes21:01
keesjin the old days it was lib.21:01
sadmacKeybuk: but right now nobody else other than us and the trains are using it, right?21:01
keesjI see.21:01
keesjtha's why the compiling upstart from bzr is so stangely not compiling nih but only configuring...21:02
sadmacoh, and ion_21:02
sadmacKeybuk: so my thoughts on not waiting for dbus reply is to simply not wait if the user NULLs out the out arguments.21:04
Keybukmy thought was just to use the async function and NULL the callback ;)21:04
sadmacthat works too.21:05

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!