Add set_consume which always takes ownership

Freeing in error path is the common pattern with set_put().
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2013-04-24 00:25:04 -04:00
parent c79bb9e4e2
commit ef42202ac8
14 changed files with 40 additions and 59 deletions
+3 -7
View File
@@ -186,13 +186,9 @@ static void load_unix_sockets(void) {
path_kill_slashes(s);
k = set_put(unix_sockets, s);
if (k < 0) {
free(s);
if (k != -EEXIST)
goto fail;
}
k = set_consume(unix_sockets, s);
if (k < 0 && k != -EEXIST)
goto fail;
}
return;