summaryrefslogtreecommitdiffstats
path: root/src/shell.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 00:53:47 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 00:53:47 +0200
commit546ac7936340312cf272969ff83317ae4d50d2b4 (patch)
tree7ecadca11430c8624d9f80aae7c348fa4d65b969 /src/shell.c
parentb22364f4af3564f0dd9a5f4e150bb09747bd5c4e (diff)
downloadfastd-546ac7936340312cf272969ff83317ae4d50d2b4.tar
fastd-546ac7936340312cf272969ff83317ae4d50d2b4.zip
Introduce and use alloc helpers
These new helpers will terminate fastd on allocation failures and add some additional convenience (allow strdup with NULL; typesafe new(type) macros).
Diffstat (limited to 'src/shell.c')
-rw-r--r--src/shell.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shell.c b/src/shell.c
index 6fba92a..87aa320 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -54,7 +54,7 @@ struct fastd_shell_env {
/** Allocated a new shell environment */
fastd_shell_env_t * fastd_shell_env_alloc(void) {
- fastd_shell_env_t *env = malloc(sizeof(fastd_shell_env_t));
+ fastd_shell_env_t *env = fastd_new(fastd_shell_env_t);
VECTOR_ALLOC(env->entries, 0);
return env;
@@ -62,7 +62,7 @@ fastd_shell_env_t * fastd_shell_env_alloc(void) {
/** Sets a variable in a shell environment */
void fastd_shell_env_set(fastd_shell_env_t *env, const char *key, const char *value) {
- shell_env_entry_t entry = {.key = key, .value = value ? strdup(value) : NULL};
+ shell_env_entry_t entry = {.key = key, .value = fastd_strdup(value)};
VECTOR_ADD(env->entries, entry);
}