int main(int argc, char **argv) { if (argc != 2 || argv[1][0] != '/') { usage(argv[0]); return -1; } SLOGD("Running: %s %s", argv[0], argv[1]); std::string target(argv[1]); destroy_key(target); if (unlink(argv[1]) != 0 && errno != ENOENT) { SLOGE("Unable to delete %s: %s", argv[1], strerror(errno)); return -1; } return 0; }
static void freebuckets(int numbuckets, mapentry_t **buckets, void (*destroy_key)(void *), void (*destroy_val)(void *)) { int b; mapentry_t *e, *tmp; for (b = 0; b < numbuckets; b++) { e = buckets[b]; while (e != NULL) { tmp = e; e = e->next; if (destroy_key && tmp->key) destroy_key (tmp->key); if (destroy_val && tmp->value) destroy_val (tmp->value); free(tmp); } } free(buckets); }