aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-07-30 15:06:04 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-07-30 15:06:04 -0700
commit18e8a131f58a54008512b05062382900027bf1d9 (patch)
tree495c1991b68c79e5f118ab35cd224e963ab25743
parent3e63da180bc6cbce7c0673419a1a4a0f021591bb (diff)
xfree() -> delete()
-rw-r--r--bp.c4
-rw-r--r--files.c16
-rw-r--r--match.c8
-rw-r--r--matchviz.c2
-rw-r--r--utils.c2
-rw-r--r--utils.h2
6 files changed, 16 insertions, 18 deletions
diff --git a/bp.c b/bp.c
index 925fe31..b36607e 100644
--- a/bp.c
+++ b/bp.c
@@ -271,7 +271,7 @@ static void confirm_replacements(file_t *f, match_t *m, confirm_t *confirm)
default: goto retry;
}
}
- if (answer) xfree(&answer);
+ if (answer) delete(&answer);
fprintf(tty_out, "\n");
}
@@ -473,7 +473,7 @@ static int process_git_files(def_t *defs, pat_t *pattern, int argc, char *argv[]
if (path[len-1] == '\n') path[len-1] = '\0';
found += process_file(defs, path, pattern);
}
- if (path) xfree(&path);
+ if (path) delete(&path);
check_nonnegative(fclose(fp), "Failed to close read end of pipe");
int status;
while (waitpid(child, &status, 0) != child) continue;
diff --git a/files.c b/files.c
index 223079b..b78ddb9 100644
--- a/files.c
+++ b/files.c
@@ -167,13 +167,11 @@ file_t *spoof_file(file_t **files, const char *filename, const char *text, ssize
//
void destroy_file(file_t **f)
{
- if ((*f)->filename) {
- xfree(&((*f)->filename));
- }
+ if ((*f)->filename)
+ delete(&((*f)->filename));
- if ((*f)->lines) {
- xfree(&((*f)->lines));
- }
+ if ((*f)->lines)
+ delete(&((*f)->lines));
if ((*f)->memory) {
if ((*f)->mmapped) {
@@ -181,16 +179,16 @@ void destroy_file(file_t **f)
"Failure to un-memory-map some memory");
(*f)->memory = NULL;
} else {
- xfree(&((*f)->memory));
+ delete(&((*f)->memory));
}
}
for (pat_t *next; (*f)->pats; (*f)->pats = next) {
next = (*f)->pats->next;
- xfree(&(*f)->pats);
+ delete(&(*f)->pats);
}
- xfree(f);
+ delete(f);
}
//
diff --git a/match.c b/match.c
index b91cfda..8bcead7 100644
--- a/match.c
+++ b/match.c
@@ -185,7 +185,7 @@ void cache_destroy(void)
cache_remove(cache.matches[i]);
}
cache.occupancy = 0;
- xfree(&cache.matches);
+ delete(&cache.matches);
cache.size = 0;
}
@@ -701,7 +701,7 @@ match_t *get_capture(match_t *m, const char **id)
if (end == *id) return NULL;
char *name = strndup(*id, (size_t)(end-*id));
match_t *cap = get_capture_by_name(m, name);
- xfree(&name);
+ delete(&name);
*id = end;
if (**id == ';') ++(*id);
return cap;
@@ -754,7 +754,7 @@ void recycle_if_unused(match_t **at_m)
for (int i = 0; m->children[i]; i++)
remove_ownership(&m->children[i]);
if (m->children != m->_children)
- xfree(&m->children);
+ delete(&m->children);
}
list_remove(m, &m->gc);
@@ -773,7 +773,7 @@ size_t recycle_all_matches(void)
match_t *m = in_use_matches;
list_remove(m, &m->gc);
if (m->children && m->children != m->_children)
- xfree(&m->children);
+ delete(&m->children);
list_prepend(&unused_matches, m, &m->gc);
++count;
}
diff --git a/matchviz.c b/matchviz.c
index 2e917ce..720ff94 100644
--- a/matchviz.c
+++ b/matchviz.c
@@ -156,7 +156,7 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char *
for (match_node_t *c = children, *next = NULL; c; c = next) {
next = c->next;
- xfree(&c);
+ delete(&c);
}
}
diff --git a/utils.c b/utils.c
index 60e12eb..39ae4cc 100644
--- a/utils.c
+++ b/utils.c
@@ -169,7 +169,7 @@ int memicmp(const void *v1, const void *v2, size_t n)
//
// Free memory, but also set the pointer to NULL for safety
//
-void xfree(void *p)
+void delete(void *p)
{
if (*(void**)p == NULL)
errx(EXIT_FAILURE, "attempt to free(NULL)");
diff --git a/utils.h b/utils.h
index cfa0a0d..550fa0d 100644
--- a/utils.h
+++ b/utils.h
@@ -37,7 +37,7 @@ int check_nonnegative(int i, const char *err_msg, ...);
__attribute__((nonnull))
int memicmp(const void *s1, const void *s2, size_t n);
__attribute__((nonnull))
-void xfree(void *p);
+void delete(void *p);
#endif
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1