i3bar: use safewrappers from libi3

This commit is contained in:
Michael Stapelberg
2011-10-21 19:30:46 +01:00
parent c65d13ff9f
commit d71db710dd
9 changed files with 37 additions and 72 deletions

View File

@ -117,7 +117,7 @@ static int workspaces_string_cb(void *params_, const unsigned char *val, unsigne
if (!strcmp(params->cur_key, "name")) {
/* Save the name */
params->workspaces_walk->name = malloc(sizeof(const unsigned char) * (len + 1));
params->workspaces_walk->name = smalloc(sizeof(const unsigned char) * (len + 1));
strncpy(params->workspaces_walk->name, (const char*) val, len);
params->workspaces_walk->name[len] = '\0';
@ -141,7 +141,7 @@ static int workspaces_string_cb(void *params_, const unsigned char *val, unsigne
if (!strcmp(params->cur_key, "output")) {
/* We add the ws to the TAILQ of the output, it belongs to */
output_name = malloc(sizeof(const unsigned char) * (len + 1));
output_name = smalloc(sizeof(const unsigned char) * (len + 1));
strncpy(output_name, (const char*) val, len);
output_name[len] = '\0';
params->workspaces_walk->output = get_output_by_name(output_name);
@ -167,7 +167,7 @@ static int workspaces_start_map_cb(void *params_) {
i3_ws *new_workspace = NULL;
if (params->cur_key == NULL) {
new_workspace = malloc(sizeof(i3_ws));
new_workspace = smalloc(sizeof(i3_ws));
new_workspace->num = -1;
new_workspace->name = NULL;
new_workspace->visible = 0;
@ -197,11 +197,7 @@ static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, uns
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
FREE(params->cur_key);
params->cur_key = malloc(sizeof(unsigned char) * (keyLen + 1));
if (params->cur_key == NULL) {
ELOG("Could not allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
params->cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
strncpy(params->cur_key, (const char*) keyVal, keyLen);
params->cur_key[keyLen] = '\0';