THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

712 lines
19KB

  1. #include "cache.h"
  2. #include "dir.h"
  3. #include "tag.h"
  4. #include "commit.h"
  5. #include "tree.h"
  6. #include "blob.h"
  7. #include "diff.h"
  8. #include "tree-walk.h"
  9. #include "revision.h"
  10. #include "list-objects.h"
  11. #include "list-objects-filter.h"
  12. #include "list-objects-filter-options.h"
  13. #include "oidmap.h"
  14. #include "oidset.h"
  15. #include "object-store.h"
  16. /* Remember to update object flag allocation in object.h */
  17. /*
  18. * FILTER_SHOWN_BUT_REVISIT -- we set this bit on tree objects
  19. * that have been shown, but should be revisited if they appear
  20. * in the traversal (until we mark it SEEN). This is a way to
  21. * let us silently de-dup calls to show() in the caller. This
  22. * is subtly different from the "revision.h:SHOWN" and the
  23. * "sha1-name.c:ONELINE_SEEN" bits. And also different from
  24. * the non-de-dup usage in pack-bitmap.c
  25. */
  26. #define FILTER_SHOWN_BUT_REVISIT (1<<21)
  27. struct subfilter {
  28. struct filter *filter;
  29. struct oidset seen;
  30. struct oidset omits;
  31. struct object_id skip_tree;
  32. unsigned is_skipping_tree : 1;
  33. };
  34. struct filter {
  35. enum list_objects_filter_result (*filter_object_fn)(
  36. struct repository *r,
  37. enum list_objects_filter_situation filter_situation,
  38. struct object *obj,
  39. const char *pathname,
  40. const char *filename,
  41. struct oidset *omits,
  42. void *filter_data);
  43. /*
  44. * Optional. If this function is supplied and the filter needs
  45. * to collect omits, then this function is called once before
  46. * free_fn is called.
  47. *
  48. * This is required because the following two conditions hold:
  49. *
  50. * a. A tree filter can add and remove objects as an object
  51. * graph is traversed.
  52. * b. A combine filter's omit set is the union of all its
  53. * subfilters, which may include tree: filters.
  54. *
  55. * As such, the omits sets must be separate sets, and can only
  56. * be unioned after the traversal is completed.
  57. */
  58. void (*finalize_omits_fn)(struct oidset *omits, void *filter_data);
  59. void (*free_fn)(void *filter_data);
  60. void *filter_data;
  61. /* If non-NULL, the filter collects a list of the omitted OIDs here. */
  62. struct oidset *omits;
  63. };
  64. static enum list_objects_filter_result filter_blobs_none(
  65. struct repository *r,
  66. enum list_objects_filter_situation filter_situation,
  67. struct object *obj,
  68. const char *pathname,
  69. const char *filename,
  70. struct oidset *omits,
  71. void *filter_data_)
  72. {
  73. switch (filter_situation) {
  74. default:
  75. BUG("unknown filter_situation: %d", filter_situation);
  76. case LOFS_BEGIN_TREE:
  77. assert(obj->type == OBJ_TREE);
  78. /* always include all tree objects */
  79. return LOFR_MARK_SEEN | LOFR_DO_SHOW;
  80. case LOFS_END_TREE:
  81. assert(obj->type == OBJ_TREE);
  82. return LOFR_ZERO;
  83. case LOFS_BLOB:
  84. assert(obj->type == OBJ_BLOB);
  85. assert((obj->flags & SEEN) == 0);
  86. if (omits)
  87. oidset_insert(omits, &obj->oid);
  88. return LOFR_MARK_SEEN; /* but not LOFR_DO_SHOW (hard omit) */
  89. }
  90. }
  91. static void filter_blobs_none__init(
  92. struct list_objects_filter_options *filter_options,
  93. struct filter *filter)
  94. {
  95. filter->filter_object_fn = filter_blobs_none;
  96. filter->free_fn = free;
  97. }
  98. /*
  99. * A filter for list-objects to omit ALL trees and blobs from the traversal.
  100. * Can OPTIONALLY collect a list of the omitted OIDs.
  101. */
  102. struct filter_trees_depth_data {
  103. /*
  104. * Maps trees to the minimum depth at which they were seen. It is not
  105. * necessary to re-traverse a tree at deeper or equal depths than it has
  106. * already been traversed.
  107. *
  108. * We can't use LOFR_MARK_SEEN for tree objects since this will prevent
  109. * it from being traversed at shallower depths.
  110. */
  111. struct oidmap seen_at_depth;
  112. unsigned long exclude_depth;
  113. unsigned long current_depth;
  114. };
  115. struct seen_map_entry {
  116. struct oidmap_entry base;
  117. size_t depth;
  118. };
  119. /* Returns 1 if the oid was in the omits set before it was invoked. */
  120. static int filter_trees_update_omits(
  121. struct object *obj,
  122. struct oidset *omits,
  123. int include_it)
  124. {
  125. if (!omits)
  126. return 0;
  127. if (include_it)
  128. return oidset_remove(omits, &obj->oid);
  129. else
  130. return oidset_insert(omits, &obj->oid);
  131. }
  132. static enum list_objects_filter_result filter_trees_depth(
  133. struct repository *r,
  134. enum list_objects_filter_situation filter_situation,
  135. struct object *obj,
  136. const char *pathname,
  137. const char *filename,
  138. struct oidset *omits,
  139. void *filter_data_)
  140. {
  141. struct filter_trees_depth_data *filter_data = filter_data_;
  142. struct seen_map_entry *seen_info;
  143. int include_it = filter_data->current_depth <
  144. filter_data->exclude_depth;
  145. int filter_res;
  146. int already_seen;
  147. /*
  148. * Note that we do not use _MARK_SEEN in order to allow re-traversal in
  149. * case we encounter a tree or blob again at a shallower depth.
  150. */
  151. switch (filter_situation) {
  152. default:
  153. BUG("unknown filter_situation: %d", filter_situation);
  154. case LOFS_END_TREE:
  155. assert(obj->type == OBJ_TREE);
  156. filter_data->current_depth--;
  157. return LOFR_ZERO;
  158. case LOFS_BLOB:
  159. filter_trees_update_omits(obj, omits, include_it);
  160. return include_it ? LOFR_MARK_SEEN | LOFR_DO_SHOW : LOFR_ZERO;
  161. case LOFS_BEGIN_TREE:
  162. seen_info = oidmap_get(
  163. &filter_data->seen_at_depth, &obj->oid);
  164. if (!seen_info) {
  165. seen_info = xcalloc(1, sizeof(*seen_info));
  166. oidcpy(&seen_info->base.oid, &obj->oid);
  167. seen_info->depth = filter_data->current_depth;
  168. oidmap_put(&filter_data->seen_at_depth, seen_info);
  169. already_seen = 0;
  170. } else {
  171. already_seen =
  172. filter_data->current_depth >= seen_info->depth;
  173. }
  174. if (already_seen) {
  175. filter_res = LOFR_SKIP_TREE;
  176. } else {
  177. int been_omitted = filter_trees_update_omits(
  178. obj, omits, include_it);
  179. seen_info->depth = filter_data->current_depth;
  180. if (include_it)
  181. filter_res = LOFR_DO_SHOW;
  182. else if (omits && !been_omitted)
  183. /*
  184. * Must update omit information of children
  185. * recursively; they have not been omitted yet.
  186. */
  187. filter_res = LOFR_ZERO;
  188. else
  189. filter_res = LOFR_SKIP_TREE;
  190. }
  191. filter_data->current_depth++;
  192. return filter_res;
  193. }
  194. }
  195. static void filter_trees_free(void *filter_data) {
  196. struct filter_trees_depth_data *d = filter_data;
  197. if (!d)
  198. return;
  199. oidmap_free(&d->seen_at_depth, 1);
  200. free(d);
  201. }
  202. static void filter_trees_depth__init(
  203. struct list_objects_filter_options *filter_options,
  204. struct filter *filter)
  205. {
  206. struct filter_trees_depth_data *d = xcalloc(1, sizeof(*d));
  207. oidmap_init(&d->seen_at_depth, 0);
  208. d->exclude_depth = filter_options->tree_exclude_depth;
  209. d->current_depth = 0;
  210. filter->filter_data = d;
  211. filter->filter_object_fn = filter_trees_depth;
  212. filter->free_fn = filter_trees_free;
  213. }
  214. /*
  215. * A filter for list-objects to omit large blobs.
  216. * And to OPTIONALLY collect a list of the omitted OIDs.
  217. */
  218. struct filter_blobs_limit_data {
  219. unsigned long max_bytes;
  220. };
  221. static enum list_objects_filter_result filter_blobs_limit(
  222. struct repository *r,
  223. enum list_objects_filter_situation filter_situation,
  224. struct object *obj,
  225. const char *pathname,
  226. const char *filename,
  227. struct oidset *omits,
  228. void *filter_data_)
  229. {
  230. struct filter_blobs_limit_data *filter_data = filter_data_;
  231. unsigned long object_length;
  232. enum object_type t;
  233. switch (filter_situation) {
  234. default:
  235. BUG("unknown filter_situation: %d", filter_situation);
  236. case LOFS_BEGIN_TREE:
  237. assert(obj->type == OBJ_TREE);
  238. /* always include all tree objects */
  239. return LOFR_MARK_SEEN | LOFR_DO_SHOW;
  240. case LOFS_END_TREE:
  241. assert(obj->type == OBJ_TREE);
  242. return LOFR_ZERO;
  243. case LOFS_BLOB:
  244. assert(obj->type == OBJ_BLOB);
  245. assert((obj->flags & SEEN) == 0);
  246. t = oid_object_info(r, &obj->oid, &object_length);
  247. if (t != OBJ_BLOB) { /* probably OBJ_NONE */
  248. /*
  249. * We DO NOT have the blob locally, so we cannot
  250. * apply the size filter criteria. Be conservative
  251. * and force show it (and let the caller deal with
  252. * the ambiguity).
  253. */
  254. goto include_it;
  255. }
  256. if (object_length < filter_data->max_bytes)
  257. goto include_it;
  258. if (omits)
  259. oidset_insert(omits, &obj->oid);
  260. return LOFR_MARK_SEEN; /* but not LOFR_DO_SHOW (hard omit) */
  261. }
  262. include_it:
  263. if (omits)
  264. oidset_remove(omits, &obj->oid);
  265. return LOFR_MARK_SEEN | LOFR_DO_SHOW;
  266. }
  267. static void filter_blobs_limit__init(
  268. struct list_objects_filter_options *filter_options,
  269. struct filter *filter)
  270. {
  271. struct filter_blobs_limit_data *d = xcalloc(1, sizeof(*d));
  272. d->max_bytes = filter_options->blob_limit_value;
  273. filter->filter_data = d;
  274. filter->filter_object_fn = filter_blobs_limit;
  275. filter->free_fn = free;
  276. }
  277. /*
  278. * A filter driven by a sparse-checkout specification to only
  279. * include blobs that a sparse checkout would populate.
  280. *
  281. * The sparse-checkout spec can be loaded from a blob with the
  282. * given OID or from a local pathname. We allow an OID because
  283. * the repo may be bare or we may be doing the filtering on the
  284. * server.
  285. */
  286. struct frame {
  287. /*
  288. * default_match is the usual default include/exclude value that
  289. * should be inherited as we recurse into directories based
  290. * upon pattern matching of the directory itself or of a
  291. * containing directory.
  292. */
  293. enum pattern_match_result default_match;
  294. /*
  295. * 1 if the directory (recursively) contains any provisionally
  296. * omitted objects.
  297. *
  298. * 0 if everything (recursively) contained in this directory
  299. * has been explicitly included (SHOWN) in the result and
  300. * the directory may be short-cut later in the traversal.
  301. */
  302. unsigned child_prov_omit : 1;
  303. };
  304. struct filter_sparse_data {
  305. struct pattern_list pl;
  306. size_t nr, alloc;
  307. struct frame *array_frame;
  308. };
  309. static enum list_objects_filter_result filter_sparse(
  310. struct repository *r,
  311. enum list_objects_filter_situation filter_situation,
  312. struct object *obj,
  313. const char *pathname,
  314. const char *filename,
  315. struct oidset *omits,
  316. void *filter_data_)
  317. {
  318. struct filter_sparse_data *filter_data = filter_data_;
  319. int dtype;
  320. struct frame *frame;
  321. enum pattern_match_result match;
  322. switch (filter_situation) {
  323. default:
  324. BUG("unknown filter_situation: %d", filter_situation);
  325. case LOFS_BEGIN_TREE:
  326. assert(obj->type == OBJ_TREE);
  327. dtype = DT_DIR;
  328. match = path_matches_pattern_list(pathname, strlen(pathname),
  329. filename, &dtype, &filter_data->pl,
  330. r->index);
  331. if (match == UNDECIDED)
  332. match = filter_data->array_frame[filter_data->nr - 1].default_match;
  333. ALLOC_GROW(filter_data->array_frame, filter_data->nr + 1,
  334. filter_data->alloc);
  335. filter_data->array_frame[filter_data->nr].default_match = match;
  336. filter_data->array_frame[filter_data->nr].child_prov_omit = 0;
  337. filter_data->nr++;
  338. /*
  339. * A directory with this tree OID may appear in multiple
  340. * places in the tree. (Think of a directory move or copy,
  341. * with no other changes, so the OID is the same, but the
  342. * full pathnames of objects within this directory are new
  343. * and may match is_excluded() patterns differently.)
  344. * So we cannot mark this directory as SEEN (yet), since
  345. * that will prevent process_tree() from revisiting this
  346. * tree object with other pathname prefixes.
  347. *
  348. * Only _DO_SHOW the tree object the first time we visit
  349. * this tree object.
  350. *
  351. * We always show all tree objects. A future optimization
  352. * may want to attempt to narrow this.
  353. */
  354. if (obj->flags & FILTER_SHOWN_BUT_REVISIT)
  355. return LOFR_ZERO;
  356. obj->flags |= FILTER_SHOWN_BUT_REVISIT;
  357. return LOFR_DO_SHOW;
  358. case LOFS_END_TREE:
  359. assert(obj->type == OBJ_TREE);
  360. assert(filter_data->nr > 1);
  361. frame = &filter_data->array_frame[--filter_data->nr];
  362. /*
  363. * Tell our parent directory if any of our children were
  364. * provisionally omitted.
  365. */
  366. filter_data->array_frame[filter_data->nr - 1].child_prov_omit |=
  367. frame->child_prov_omit;
  368. /*
  369. * If there are NO provisionally omitted child objects (ALL child
  370. * objects in this folder were INCLUDED), then we can mark the
  371. * folder as SEEN (so we will not have to revisit it again).
  372. */
  373. if (!frame->child_prov_omit)
  374. return LOFR_MARK_SEEN;
  375. return LOFR_ZERO;
  376. case LOFS_BLOB:
  377. assert(obj->type == OBJ_BLOB);
  378. assert((obj->flags & SEEN) == 0);
  379. frame = &filter_data->array_frame[filter_data->nr - 1];
  380. dtype = DT_REG;
  381. match = path_matches_pattern_list(pathname, strlen(pathname),
  382. filename, &dtype, &filter_data->pl,
  383. r->index);
  384. if (match == UNDECIDED)
  385. match = frame->default_match;
  386. if (match == MATCHED) {
  387. if (omits)
  388. oidset_remove(omits, &obj->oid);
  389. return LOFR_MARK_SEEN | LOFR_DO_SHOW;
  390. }
  391. /*
  392. * Provisionally omit it. We've already established that
  393. * this pathname is not in the sparse-checkout specification
  394. * with the CURRENT pathname, so we *WANT* to omit this blob.
  395. *
  396. * However, a pathname elsewhere in the tree may also
  397. * reference this same blob, so we cannot reject it yet.
  398. * Leave the LOFR_ bits unset so that if the blob appears
  399. * again in the traversal, we will be asked again.
  400. */
  401. if (omits)
  402. oidset_insert(omits, &obj->oid);
  403. /*
  404. * Remember that at least 1 blob in this tree was
  405. * provisionally omitted. This prevents us from short
  406. * cutting the tree in future iterations.
  407. */
  408. frame->child_prov_omit = 1;
  409. return LOFR_ZERO;
  410. }
  411. }
  412. static void filter_sparse_free(void *filter_data)
  413. {
  414. struct filter_sparse_data *d = filter_data;
  415. free(d->array_frame);
  416. free(d);
  417. }
  418. static void filter_sparse_oid__init(
  419. struct list_objects_filter_options *filter_options,
  420. struct filter *filter)
  421. {
  422. struct filter_sparse_data *d = xcalloc(1, sizeof(*d));
  423. struct object_context oc;
  424. struct object_id sparse_oid;
  425. if (get_oid_with_context(the_repository,
  426. filter_options->sparse_oid_name,
  427. GET_OID_BLOB, &sparse_oid, &oc))
  428. die(_("unable to access sparse blob in '%s'"),
  429. filter_options->sparse_oid_name);
  430. if (add_patterns_from_blob_to_list(&sparse_oid, "", 0, &d->pl) < 0)
  431. die(_("unable to parse sparse filter data in %s"),
  432. oid_to_hex(&sparse_oid));
  433. ALLOC_GROW(d->array_frame, d->nr + 1, d->alloc);
  434. d->array_frame[d->nr].default_match = 0; /* default to include */
  435. d->array_frame[d->nr].child_prov_omit = 0;
  436. d->nr++;
  437. filter->filter_data = d;
  438. filter->filter_object_fn = filter_sparse;
  439. filter->free_fn = filter_sparse_free;
  440. }
  441. /* A filter which only shows objects shown by all sub-filters. */
  442. struct combine_filter_data {
  443. struct subfilter *sub;
  444. size_t nr;
  445. };
  446. static enum list_objects_filter_result process_subfilter(
  447. struct repository *r,
  448. enum list_objects_filter_situation filter_situation,
  449. struct object *obj,
  450. const char *pathname,
  451. const char *filename,
  452. struct subfilter *sub)
  453. {
  454. enum list_objects_filter_result result;
  455. /*
  456. * Check and update is_skipping_tree before oidset_contains so
  457. * that is_skipping_tree gets unset even when the object is
  458. * marked as seen. As of this writing, no filter uses
  459. * LOFR_MARK_SEEN on trees that also uses LOFR_SKIP_TREE, so the
  460. * ordering is only theoretically important. Be cautious if you
  461. * change the order of the below checks and more filters have
  462. * been added!
  463. */
  464. if (sub->is_skipping_tree) {
  465. if (filter_situation == LOFS_END_TREE &&
  466. oideq(&obj->oid, &sub->skip_tree))
  467. sub->is_skipping_tree = 0;
  468. else
  469. return LOFR_ZERO;
  470. }
  471. if (oidset_contains(&sub->seen, &obj->oid))
  472. return LOFR_ZERO;
  473. result = list_objects_filter__filter_object(
  474. r, filter_situation, obj, pathname, filename, sub->filter);
  475. if (result & LOFR_MARK_SEEN)
  476. oidset_insert(&sub->seen, &obj->oid);
  477. if (result & LOFR_SKIP_TREE) {
  478. sub->is_skipping_tree = 1;
  479. sub->skip_tree = obj->oid;
  480. }
  481. return result;
  482. }
  483. static enum list_objects_filter_result filter_combine(
  484. struct repository *r,
  485. enum list_objects_filter_situation filter_situation,
  486. struct object *obj,
  487. const char *pathname,
  488. const char *filename,
  489. struct oidset *omits,
  490. void *filter_data)
  491. {
  492. struct combine_filter_data *d = filter_data;
  493. enum list_objects_filter_result combined_result =
  494. LOFR_DO_SHOW | LOFR_MARK_SEEN | LOFR_SKIP_TREE;
  495. size_t sub;
  496. for (sub = 0; sub < d->nr; sub++) {
  497. enum list_objects_filter_result sub_result = process_subfilter(
  498. r, filter_situation, obj, pathname, filename,
  499. &d->sub[sub]);
  500. if (!(sub_result & LOFR_DO_SHOW))
  501. combined_result &= ~LOFR_DO_SHOW;
  502. if (!(sub_result & LOFR_MARK_SEEN))
  503. combined_result &= ~LOFR_MARK_SEEN;
  504. if (!d->sub[sub].is_skipping_tree)
  505. combined_result &= ~LOFR_SKIP_TREE;
  506. }
  507. return combined_result;
  508. }
  509. static void filter_combine__free(void *filter_data)
  510. {
  511. struct combine_filter_data *d = filter_data;
  512. size_t sub;
  513. for (sub = 0; sub < d->nr; sub++) {
  514. list_objects_filter__free(d->sub[sub].filter);
  515. oidset_clear(&d->sub[sub].seen);
  516. if (d->sub[sub].omits.set.size)
  517. BUG("expected oidset to be cleared already");
  518. }
  519. free(d->sub);
  520. }
  521. static void add_all(struct oidset *dest, struct oidset *src) {
  522. struct oidset_iter iter;
  523. struct object_id *src_oid;
  524. oidset_iter_init(src, &iter);
  525. while ((src_oid = oidset_iter_next(&iter)) != NULL)
  526. oidset_insert(dest, src_oid);
  527. }
  528. static void filter_combine__finalize_omits(
  529. struct oidset *omits,
  530. void *filter_data)
  531. {
  532. struct combine_filter_data *d = filter_data;
  533. size_t sub;
  534. for (sub = 0; sub < d->nr; sub++) {
  535. add_all(omits, &d->sub[sub].omits);
  536. oidset_clear(&d->sub[sub].omits);
  537. }
  538. }
  539. static void filter_combine__init(
  540. struct list_objects_filter_options *filter_options,
  541. struct filter* filter)
  542. {
  543. struct combine_filter_data *d = xcalloc(1, sizeof(*d));
  544. size_t sub;
  545. d->nr = filter_options->sub_nr;
  546. d->sub = xcalloc(d->nr, sizeof(*d->sub));
  547. for (sub = 0; sub < d->nr; sub++)
  548. d->sub[sub].filter = list_objects_filter__init(
  549. filter->omits ? &d->sub[sub].omits : NULL,
  550. &filter_options->sub[sub]);
  551. filter->filter_data = d;
  552. filter->filter_object_fn = filter_combine;
  553. filter->free_fn = filter_combine__free;
  554. filter->finalize_omits_fn = filter_combine__finalize_omits;
  555. }
  556. typedef void (*filter_init_fn)(
  557. struct list_objects_filter_options *filter_options,
  558. struct filter *filter);
  559. /*
  560. * Must match "enum list_objects_filter_choice".
  561. */
  562. static filter_init_fn s_filters[] = {
  563. NULL,
  564. filter_blobs_none__init,
  565. filter_blobs_limit__init,
  566. filter_trees_depth__init,
  567. filter_sparse_oid__init,
  568. filter_combine__init,
  569. };
  570. struct filter *list_objects_filter__init(
  571. struct oidset *omitted,
  572. struct list_objects_filter_options *filter_options)
  573. {
  574. struct filter *filter;
  575. filter_init_fn init_fn;
  576. assert((sizeof(s_filters) / sizeof(s_filters[0])) == LOFC__COUNT);
  577. if (filter_options->choice >= LOFC__COUNT)
  578. BUG("invalid list-objects filter choice: %d",
  579. filter_options->choice);
  580. init_fn = s_filters[filter_options->choice];
  581. if (!init_fn)
  582. return NULL;
  583. filter = xcalloc(1, sizeof(*filter));
  584. filter->omits = omitted;
  585. init_fn(filter_options, filter);
  586. return filter;
  587. }
  588. enum list_objects_filter_result list_objects_filter__filter_object(
  589. struct repository *r,
  590. enum list_objects_filter_situation filter_situation,
  591. struct object *obj,
  592. const char *pathname,
  593. const char *filename,
  594. struct filter *filter)
  595. {
  596. if (filter && (obj->flags & NOT_USER_GIVEN))
  597. return filter->filter_object_fn(r, filter_situation, obj,
  598. pathname, filename,
  599. filter->omits,
  600. filter->filter_data);
  601. /*
  602. * No filter is active or user gave object explicitly. In this case,
  603. * always show the object (except when LOFS_END_TREE, since this tree
  604. * had already been shown when LOFS_BEGIN_TREE).
  605. */
  606. if (filter_situation == LOFS_END_TREE)
  607. return 0;
  608. return LOFR_MARK_SEEN | LOFR_DO_SHOW;
  609. }
  610. void list_objects_filter__free(struct filter *filter)
  611. {
  612. if (!filter)
  613. return;
  614. if (filter->finalize_omits_fn && filter->omits)
  615. filter->finalize_omits_fn(filter->omits, filter->filter_data);
  616. filter->free_fn(filter->filter_data);
  617. free(filter);
  618. }