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