Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Simplify _pacman_list_remove (make it not destroy list head, will help to make list not pointers in classes).

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=0ea56fb040ef270ff58e9208752569cb7d6f760f

commit 0ea56fb040ef270ff58e9208752569cb7d6f760f
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 22:28:14 2014 +0200

libpacman: Simplify _pacman_list_remove (make it not destroy list head, will help to make list not
pointers in classes).

diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp
index 0cf5de6..98a8f38 100644
--- a/lib/libpacman/pacman.cpp
+++ b/lib/libpacman/pacman.cpp
 <at>  <at>  -116,7 +116,7  <at>  <at>  int pacman_release(void)
pacman_db_unregister(c_cast(handle->db_local));
}
/* and also sync ones */
-	while(handle->dbs_sync) {
+	while(!handle->dbs_sync->empty()) {
/* db_unregister() will also update the handle->dbs_sync list */
pacman_db_unregister(f_ptrlistitem_data(handle->dbs_sync->begin()));
}
diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp
index c097d1b..4ee403c 100644
--- a/lib/libpacman/util/fptrlist.cpp
+++ b/lib/libpacman/util/fptrlist.cpp
 <at>  <at>  -76,48 +76,55  <at>  <at>  FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn)
*/
FPtrList *_pacman_list_remove(FPtrList *haystack, void *needle, _pacman_fn_cmp fn, void **data)
{
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make Database::servers not a pointer.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=eeba15114d37ce8527a146ceed98e096212f3385

commit eeba15114d37ce8527a146ceed98e096212f3385
Author: Michel Hermier <hermier@...>
Date:   Wed Sep 3 00:28:03 2014 +0200

libpacman: Make Database::servers not a pointer.

diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp
index 29116b5..ffa1aff 100644
--- a/lib/libpacman/db.cpp
+++ b/lib/libpacman/db.cpp
 <at>  <at>  -80,7 +80,7  <at>  <at>  Database::Database(Handle *handle, const char *treename)

Database::~Database()
{
-	FREELISTSERVERS(servers);
+	servers.clear(/* _pacman_server_free */);
free(path);
}

 <at>  <at>  -91,7 +91,7  <at>  <at>  bool Database::add_server(const char *url)
ASSERT(!_pacman_strempty(url), RET_ERR(PM_ERR_WRONG_ARGS, false));
ASSERT((server = _pacman_server_new(url)) != NULL, return false);

-	servers = servers->add(server);
+	servers.add(server);
_pacman_log(PM_LOG_FLOW2, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
treename(), server->protocol, server->server, server->path);
return true;
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Simplify f_ptrlist_add_sorted and f_ptrlist_clear (so it can work with head in place).

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b83c595fa6b6e6785057ba4c8b4a22892a3c66fc

commit b83c595fa6b6e6785057ba4c8b4a22892a3c66fc
Author: Michel Hermier <hermier@...>
Date:   Wed Sep 3 00:13:44 2014 +0200

libpacman: Simplify f_ptrlist_add_sorted and f_ptrlist_clear (so it can work with head in place).

diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp
index fa9b93c..ba90a0f 100644
--- a/lib/libpacman/util/fptrlist.cpp
+++ b/lib/libpacman/util/fptrlist.cpp
 <at>  <at>  -46,13 +46,11  <at>  <at>  FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn)
f_ptrlistitem_insert_after(next, list);
} else {
#endif
-	FPtrListIterator *add, *previous = NULL, *iter = f_ptrlist_first(list);
-
-	add = new FCListItem();
+	FPtrListIterator *add = new FCListItem();
add->m_data = data;

/* Find insertion point. */
-	previous = list;
+	FPtrListIterator *previous = list;
for(FPtrListIterator *end = f_ptrlist_end(list); previous->next() != end; previous =
previous->next()) {
if(fn(f_ptrlistitem_data(add), f_ptrlistitem_data(previous->next())) <= 0) {
break;
 <at>  <at>  -235,8 +233,21  <at>  <at>  FPtrList *f_ptrlist_add(FPtrList *list, void *data)
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make c_cast able to also cast references.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=a2f925059b8fdd16dca95e07d92f12b7ad894c3f

commit a2f925059b8fdd16dca95e07d92f12b7ad894c3f
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 23:47:57 2014 +0200

libpacman: Make c_cast able to also cast references.

diff --git a/lib/libpacman/pacman_p.h b/lib/libpacman/pacman_p.h
index 611e1d9..a1b225b 100644
--- a/lib/libpacman/pacman_p.h
+++ b/lib/libpacman/pacman_p.h
 <at>  <at>  -28,6 +28,9  <at>  <at> 
#define DEFINE_CAST(c_type, cxx_type)         \
static inline c_type *c_cast(cxx_type *obj)   \
{ return (c_type *)obj; }                     \
+																							\
+static inline c_type *c_cast(cxx_type &obj)   \
+{ return (c_type *)&obj; }                    \
\
static inline cxx_type *cxx_cast(c_type *obj) \
{ return (cxx_type *)obj; }
Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make Database::pkgcache not a pointer.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=431679ff4f988be1d0e35d85b0ed86bb612fa000

commit 431679ff4f988be1d0e35d85b0ed86bb612fa000
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 23:49:52 2014 +0200

libpacman: Make Database::pkgcache not a pointer.

diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp
index 87ee102..982f6c8 100644
--- a/lib/libpacman/cache.cpp
+++ b/lib/libpacman/cache.cpp
 <at>  <at>  -72,7 +72,7  <at>  <at>  int _pacman_db_load_pkgcache(Database *db)
db->rewind();
while((info = db->readpkg(inforeq)) != NULL) {
/* add to the collective */
-		db->pkgcache = f_ptrlist_add_sorted(db->pkgcache, info, _pacman_pkg_cmp);
+		f_ptrlist_add_sorted(&db->pkgcache, info, _pacman_pkg_cmp);
}

return(0);
 <at>  <at>  -81,27 +81,24  <at>  <at>  int _pacman_db_load_pkgcache(Database *db)
void _pacman_db_free_pkgcache(Database *db)
{
ASSERT(db != NULL, pm_errno = PM_ERR_DB_NULL; return);
-	if(db->pkgcache->empty()) {
+	if(db->pkgcache.empty()) {
return;
}

(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make Database::grpcache not a pointer.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=cb1eca775e3d01942637966e8dd4280a79406f99

commit cb1eca775e3d01942637966e8dd4280a79406f99
Author: Michel Hermier <hermier@...>
Date:   Wed Sep 3 00:14:33 2014 +0200

libpacman: Make Database::grpcache not a pointer.

diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp
index 982f6c8..478fce3 100644
--- a/lib/libpacman/cache.cpp
+++ b/lib/libpacman/cache.cpp
 <at>  <at>  -178,11 +178,11  <at>  <at>  int _pacman_db_load_grpcache(Database *db)
for(auto git = groups->begin(), git_end = groups->end(); git != git_end; git = git->next()) {
const char *grp_name = f_stringlistitem_to_str(git);

-			Group *grp = _pacman_db_get_grpfromlist(db->grpcache, grp_name);
+			Group *grp = _pacman_db_get_grpfromlist(&db->grpcache, grp_name);

if(grp == NULL) {
grp = new Group(grp_name);
-				db->grpcache = f_ptrlist_add_sorted(db->grpcache, grp, _pacman_grp_cmp);
+				f_ptrlist_add_sorted(&db->grpcache, grp, _pacman_grp_cmp);
}
if(!_pacman_list_is_strin(pkg->name(), grp->packages)) {
grp->packages = f_ptrlist_add_sorted(grp->packages, pkg->name(), strcmp);
 <at>  <at>  -202,27 +202,23  <at>  <at>  int _pacman_db_clear_grpcache(Database *db)

ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));

(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make f_ptrlist_add_sorted manage before head insertion differently (do not replace head, move head data instead to a new item).

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=571d3e7b9b797e260284c3c7194ece39becae4af

commit 571d3e7b9b797e260284c3c7194ece39becae4af
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 22:35:22 2014 +0200

libpacman: Make f_ptrlist_add_sorted manage before head insertion differently (do not replace head,
move head data instead to a new item).

diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp
index 4ee403c..c833c58 100644
--- a/lib/libpacman/util/fptrlist.cpp
+++ b/lib/libpacman/util/fptrlist.cpp
 <at>  <at>  -39,12 +39,11  <at>  <at>  FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn)
if(list->m_data == NULL) {
list->m_data = data;
} else if(fn(data, list->m_data) <= 0) {
-		/* Insert before head */
-		FPtrList *list_new = new FCListItem();
-		list_new->m_data = data;
-		list_new->m_next = list;
-		list->m_previous = list_new;
-		list = list_new;
+		/* Insert before in head */
+		FPtrList *next = new FCListItem();
+		next->m_data = list->m_data;
+		list->m_data = data;
+		f_ptrlistitem_insert_after(next, list);
} else {
#endif
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Now that _pacman_list_remove don't alter list head, make it return a boolean for success indication.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=deeb0ef54c77f953c0d221fec1c4c77f2e2f8859

commit deeb0ef54c77f953c0d221fec1c4c77f2e2f8859
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 23:04:54 2014 +0200

libpacman: Now that _pacman_list_remove don't alter list head, make it return a boolean for success indication.

diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp
index fb6ede0..87ee102 100644
--- a/lib/libpacman/cache.cpp
+++ b/lib/libpacman/cache.cpp
 <at>  <at>  -129,8 +129,7  <at>  <at>  int _pacman_db_remove_pkgfromcache(Database *db, Package *pkg)
return(-1);
}

-	db->pkgcache = _pacman_list_remove(db->pkgcache, pkg, f_ptrcmp, (void **)&data);
-	if(data == NULL) {
+	if(!_pacman_list_remove(db->pkgcache, pkg, f_ptrcmp, (void **)&data)) {
/* package not found */
return(-1);
}
diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp
index b1a1140..3aa3e6d 100644
--- a/lib/libpacman/deps.cpp
+++ b/lib/libpacman/deps.cpp
 <at>  <at>  -750,8 +750,7  <at>  <at>  int pacman_output_generate(FPtrList *targets, FPtrList *dblist) {
pkg = db->readpkg(inforeq);
while(pkg != NULL) {
const char *pname = pkg->name();
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Simplify f_ptrlist_add_sorted.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=4e633cc03d6e56561b5622052e78919ad27d1529

commit 4e633cc03d6e56561b5622052e78919ad27d1529
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 17:15:33 2014 +0200

libpacman: Simplify f_ptrlist_add_sorted.

diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp
index 56f892f..c097d1b 100644
--- a/lib/libpacman/util/fptrlist.cpp
+++ b/lib/libpacman/util/fptrlist.cpp
 <at>  <at>  -31,43 +31,41  <at>  <at> 
*/
FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn)
{
+	if(list == NULL) {
+		list = new FPtrList();
+	}
+
#ifndef F_NOCOMPAT
-	FPtrListIterator *add, *end = f_ptrlist_end(list), *previous = NULL, *iter = f_ptrlist_first(list);
+	if(list->m_data == NULL) {
+		list->m_data = data;
+	} else if(fn(data, list->m_data) <= 0) {
+		/* Insert before head */
+		FPtrList *list_new = new FCListItem();
+		list_new->m_data = data;
+		list_new->m_next = list;
+		list->m_previous = list_new;
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make Handle::noextract not a pointer.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=933e5a74dd6203e7a50b651a7d777391f0e7c9f9

commit 933e5a74dd6203e7a50b651a7d777391f0e7c9f9
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 21:27:06 2014 +0200

libpacman: Make Handle::noextract not a pointer.

diff --git a/lib/libpacman/handle.cpp b/lib/libpacman/handle.cpp
index c2e1b2c..6361bc4 100644
--- a/lib/libpacman/handle.cpp
+++ b/lib/libpacman/handle.cpp
 <at>  <at>  -108,7 +108,6  <at>  <at>  Handle::~Handle()
free(xfercommand);
FREELIST(dbs_sync);
FREELIST(noupgrade);
-	FREELIST(noextract);
}

int Handle::lock()
diff --git a/lib/libpacman/handle.h b/lib/libpacman/handle.h
index cdf4b44..a895659 100644
--- a/lib/libpacman/handle.h
+++ b/lib/libpacman/handle.h
 <at>  <at>  -75,7 +75,7  <at>  <at>  public:
char *hooksdir;
char *triggersdir;
FPtrList *noupgrade; /* List of strings */
-	FPtrList *noextract; /* List of strings */
+	FStringList noextract;
(Continue reading)

Michel Hermier | 2 Sep 23:19 2014
Picon

pacman-g2: libpacman: Make Handle::ignorepkg not a pointer.

Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=bd5d6f58d87330f3fb088bbcfa1efb516e21442f

commit bd5d6f58d87330f3fb088bbcfa1efb516e21442f
Author: Michel Hermier <hermier@...>
Date:   Tue Sep 2 21:21:38 2014 +0200

libpacman: Make Handle::ignorepkg not a pointer.

diff --git a/lib/libpacman/config_parser.cpp b/lib/libpacman/config_parser.cpp
index 3630144..a236c6b 100644
--- a/lib/libpacman/config_parser.cpp
+++ b/lib/libpacman/config_parser.cpp
 <at>  <at>  -88,7 +88,7  <at>  <at>  int _pacman_parse_config(Handle *handle, const char *file, pacman_cb_db_register
db = handle->createDatabase(section, callback);
}
} else {
-		FREELIST(handle->ignorepkg);
+		handle->ignorepkg.clear();
handle->holdpkg.clear();
}

diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp
index 78aca22..b1a1140 100644
--- a/lib/libpacman/deps.cpp
+++ b/lib/libpacman/deps.cpp
 <at>  <at>  -631,7 +631,7  <at>  <at>  int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, FPtrList *list,
* something we're not supposed to.
*/
int usedep = 1;
-			if(_pacman_list_is_strin(ps->name(), handle->ignorepkg)) {
(Continue reading)


Gmane