Reduce some code around frees
This commit is contained in:
parent
565d38c5af
commit
50880db2c5
|
@ -216,7 +216,7 @@ static const char *get_string(const char *identifier) {
|
|||
|
||||
static void clear_stack(void) {
|
||||
for (int c = 0; c < 10; c++) {
|
||||
if (stack[c].type == STACK_STR && stack[c].val.str != NULL)
|
||||
if (stack[c].type == STACK_STR)
|
||||
free(stack[c].val.str);
|
||||
stack[c].identifier = NULL;
|
||||
stack[c].val.str = NULL;
|
||||
|
|
|
@ -54,9 +54,7 @@ void init_dpi(void) {
|
|||
DLOG("Found Xft.dpi = %ld.\n", dpi);
|
||||
|
||||
init_dpi_end:
|
||||
if (resource != NULL) {
|
||||
free(resource);
|
||||
}
|
||||
|
||||
if (database != NULL) {
|
||||
xcb_xrm_database_free(database);
|
||||
|
|
|
@ -224,9 +224,7 @@ i3Font load_font(const char *pattern, const bool fallback) {
|
|||
error->error_code);
|
||||
}
|
||||
}
|
||||
if (error != NULL) {
|
||||
free(error);
|
||||
}
|
||||
|
||||
font.pattern = sstrdup(pattern);
|
||||
LOG("Using X font %s\n", pattern);
|
||||
|
@ -275,7 +273,6 @@ void free_font(void) {
|
|||
case FONT_TYPE_XCB: {
|
||||
/* Close the font and free the info */
|
||||
xcb_close_font(conn, savedFont->specific.xcb.id);
|
||||
if (savedFont->specific.xcb.info)
|
||||
free(savedFont->specific.xcb.info);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ static long get_long(const char *identifier) {
|
|||
// TODO move to a common util
|
||||
static void clear_stack(void) {
|
||||
for (int c = 0; c < 10; c++) {
|
||||
if (stack[c].type == STACK_STR && stack[c].val.str != NULL)
|
||||
if (stack[c].type == STACK_STR)
|
||||
free(stack[c].val.str);
|
||||
stack[c].identifier = NULL;
|
||||
stack[c].val.str = NULL;
|
||||
|
|
|
@ -171,7 +171,7 @@ static long get_long(const char *identifier) {
|
|||
|
||||
static void clear_stack(void) {
|
||||
for (int c = 0; c < 10; c++) {
|
||||
if (stack[c].type == STACK_STR && stack[c].val.str != NULL)
|
||||
if (stack[c].type == STACK_STR)
|
||||
free(stack[c].val.str);
|
||||
stack[c].identifier = NULL;
|
||||
stack[c].val.str = NULL;
|
||||
|
|
|
@ -153,8 +153,7 @@ static int json_end_map(void *ctx) {
|
|||
free(marks[i]);
|
||||
}
|
||||
|
||||
free(marks);
|
||||
marks = NULL;
|
||||
FREE(marks);
|
||||
num_marks = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -501,8 +501,7 @@ ssize_t slurp(const char *path, char **buf) {
|
|||
fclose(f);
|
||||
if ((ssize_t)n != stbuf.st_size) {
|
||||
ELOG("File \"%s\" could not be read entirely: got %zd, want %" PRIi64 "\n", path, n, (int64_t)stbuf.st_size);
|
||||
free(*buf);
|
||||
*buf = NULL;
|
||||
FREE(*buf);
|
||||
return -1;
|
||||
}
|
||||
return (ssize_t)n;
|
||||
|
|
Loading…
Reference in New Issue