diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-07-30 15:06:04 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-07-30 15:06:04 -0700 |
| commit | 18e8a131f58a54008512b05062382900027bf1d9 (patch) | |
| tree | 495c1991b68c79e5f118ab35cd224e963ab25743 | |
| parent | 3e63da180bc6cbce7c0673419a1a4a0f021591bb (diff) | |
xfree() -> delete()
| -rw-r--r-- | bp.c | 4 | ||||
| -rw-r--r-- | files.c | 16 | ||||
| -rw-r--r-- | match.c | 8 | ||||
| -rw-r--r-- | matchviz.c | 2 | ||||
| -rw-r--r-- | utils.c | 2 | ||||
| -rw-r--r-- | utils.h | 2 |
6 files changed, 16 insertions, 18 deletions
@@ -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; @@ -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); } // @@ -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; } @@ -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); } } @@ -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)"); @@ -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 |
