core/manager: move environment serialization out to basic/env-util.c
This protocol is generally useful, we might just as well reuse it for the env. generators. The implementation is changed a bit: instead of making a new strv and freeing the old one, just mutate the original. This is much faster with larger arrays, while in fact atomicity is preserved, since we only either insert the new entry or not, without being in inconsistent state. v2: - fix confusion with return value
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
@@ -50,3 +51,6 @@ char *strv_env_get_n(char **l, const char *name, size_t k) _pure_;
|
||||
char *strv_env_get(char **x, const char *n) _pure_;
|
||||
|
||||
int getenv_bool(const char *p);
|
||||
|
||||
int serialize_environment(FILE *f, char **environment);
|
||||
int deserialize_environment(char ***environment, const char *line);
|
||||
|
||||
Reference in New Issue
Block a user