socsvn commit: r256972 - soc2013/mattbw/backend
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Thu Sep 5 21:10:18 UTC 2013
Author: mattbw
Date: Thu Sep 5 21:10:17 2013
New Revision: 256972
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256972
Log:
Split search body into two functions.
Modified:
soc2013/mattbw/backend/search.c
Modified: soc2013/mattbw/backend/search.c
==============================================================================
--- soc2013/mattbw/backend/search.c Thu Sep 5 20:50:52 2013 (r256971)
+++ soc2013/mattbw/backend/search.c Thu Sep 5 21:10:17 2013 (r256972)
@@ -26,6 +26,8 @@
#include "pkgutils.h" /* pkgutils_... */
#include "search.h" /* search_... */
+static void search_do_with_it(struct search *search, struct pkgdb_it *it);
+
/*
* Performs the search specified by the given "struct search" and emits each
* result according to the likewise-specified filter set.
@@ -33,12 +35,10 @@
bool
search_do(struct search *search)
{
- bool success;
struct pkgdb_it *it;
assert(search != NULL);
- success = false;
it = pkgdb_search(search->db,
search->term,
search->type,
@@ -47,23 +47,31 @@
NULL);
if (it != NULL) {
- struct pkg *pkg;
+ search_do_with_it(search, it);
+ pkgdb_it_free(it);
+ }
+
+ return (it != NULL);
+}
- pkg = NULL;
- while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
- assert(pkg != NULL);
-
- pkgutils_add_old_version(search->db, pkg, NULL);
- emit_filtered_package(pkg,
- search->backend,
- search->filters,
- pkgutils_pkg_current_state(pkg));
- }
+static void
+search_do_with_it(struct search *search, struct pkgdb_it *it)
+{
+ struct pkg *pkg;
+
+ assert(search != NULL);
+ assert(it != NULL);
- success = true;
- pkg_free(pkg);
+ pkg = NULL;
+ while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
+ assert(pkg != NULL);
+
+ pkgutils_add_old_version(search->db, pkg, NULL);
+ emit_filtered_package(pkg,
+ search->backend,
+ search->filters,
+ pkgutils_pkg_current_state(pkg));
}
- pkgdb_it_free(it);
- return success;
+ pkg_free(pkg);
}
More information about the svn-soc-all
mailing list