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

commit 358d903682ebb4a199ab09085be77979376567cd
Author: Michel Hermier <[email protected]>
Date:   Wed Sep 24 19:04:18 2014 +0200

libpacman: Drop FVisitor.

diff --git a/lib/libpacman/fstring.h b/lib/libpacman/fstring.h
index 76a0774..9f53119 100644
--- a/lib/libpacman/fstring.h
+++ b/lib/libpacman/fstring.h
@@ -23,8 +23,6 @@

#include <string.h>

-#include "util/fcallback.h"
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/libpacman/fstring/basename.c b/lib/libpacman/fstring/basename.c
index 13ca6a0..3b54253 100644
--- a/lib/libpacman/fstring/basename.c
+++ b/lib/libpacman/fstring/basename.c
@@ -27,6 +27,8 @@

#include <limits.h>

+#include "util.h"
+
char *f_basename(const char *path)
{
static char buffer[PATH_MAX];
diff --git a/lib/libpacman/fstring/case.c b/lib/libpacman/fstring/case.c
index 423216c..f9f6022 100644
--- a/lib/libpacman/fstring/case.c
+++ b/lib/libpacman/fstring/case.c
@@ -22,6 +22,7 @@
#include "config.h"

#include "fstring.h"
+#include "util.h"

#include <ctype.h>

diff --git a/lib/libpacman/fstring/dirname.c b/lib/libpacman/fstring/dirname.c
index 2259fd0..0ba6dbb 100644
--- a/lib/libpacman/fstring/dirname.c
+++ b/lib/libpacman/fstring/dirname.c
@@ -24,6 +24,7 @@
#include <libgen.h> // Must be before string.h

#include "fstring.h"
+#include "util.h"

#include <limits.h>

diff --git a/lib/libpacman/util/fcallback.h b/lib/libpacman/util/fcallback.h
deleted file mode 100644
index ebe242e..0000000
--- a/lib/libpacman/util/fcallback.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  fcallbacks.h
- *
- *  Copyright (c) 2013-2014 by Michel Hermier <[email protected]>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- *  USA.
- */
-#ifndef F_CALLBACKS_H
-#define F_CALLBACKS_H
-
-#include "fstdlib.h"
-#include "util.h"
-
-typedef void (*FVisitorFunc)(void *ptr, void *visitor_data);
-
-typedef struct FVisitor FVisitor;
-
-struct FVisitor {
-#ifdef __cplusplus
-       FVisitor()
-               : fn(NULL), data(NULL)
-       { }
-
-       FVisitor(FVisitorFunc _fn, void *_data)
-               : fn(_fn), data(_data)
-       { }
-#endif
-
-       FVisitorFunc fn;
-       void *data;
-};
-
-static inline
-int f_visitor_init(FVisitor *self, FVisitorFunc fn, void *data)
-{
-       ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
-       self->fn = fn;
-       self->data = data;
-       return 0;
-}
-
-static inline
-int f_visitor_fini(FVisitor *self)
-{
-       ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
-       self->fn = NULL;
-       self->data = NULL;
-       return 0;
-}
-
-static inline
-FVisitor *f_visitor_new(FVisitorFunc fn, void *data)
-{
-       FVisitor *self;
-
-       ASSERT((self = (FVisitor *)f_zalloc(sizeof(*self))) != NULL, return 
NULL);
-       f_visitor_init(self, fn, data);
-       return self;
-}
-
-static inline
-int f_visitor_delete(FVisitor *self)
-{
-       ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
-       f_visitor_fini(self);
-       free(self);
-       return 0;
-}
-
-static inline
-void f_visit(void *ptr, const FVisitor *visitor) {
-       ASSERT(visitor != NULL, return);
-       ASSERT(visitor->fn != NULL, return);
-
-       visitor->fn(ptr, visitor->data);
-}
-
-#endif /* F_CALLBACKS_H */
-
-/* vim: set ts=2 sw=2 noet: */
\ No newline at end of file
diff --git a/lib/libpacman/util/fdispatchlogger.cpp 
b/lib/libpacman/util/fdispatchlogger.cpp
index 26f29af..f67ab39 100644
--- a/lib/libpacman/util/fdispatchlogger.cpp
+++ b/lib/libpacman/util/fdispatchlogger.cpp
@@ -45,7 +45,7 @@ FDispatchLogger *f_dispatchlogger_new(unsigned char mask)
{
FDispatchLogger *dispatchlogger;

-       if ((dispatchlogger = (FDispatchLogger 
*)f_zalloc(sizeof(*dispatchlogger))) == NULL) {
+       if((dispatchlogger = new FDispatchLogger()) == NULL) {
return NULL;
}
f_logger_init(&dispatchlogger->base, mask, f_dispatchlogger_log, 
f_ptrlist_new());
diff --git a/lib/libpacman/util/flist.h b/lib/libpacman/util/flist.h
index 163f295..5a6563c 100644
--- a/lib/libpacman/util/flist.h
+++ b/lib/libpacman/util/flist.h
@@ -24,8 +24,8 @@

#include "pacman.h"

-#include "util/fcallback.h"
#include "util/fptrlist.h"
+#include "util.h"

/* Sort comparison callback function declaration */
typedef int (*_pacman_fn_cmp)(const void *, const void *);
diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp
index b4f2606..e9f2832 100644
--- a/lib/libpacman/util/fptrlist.cpp
+++ b/lib/libpacman/util/fptrlist.cpp
@@ -92,11 +92,11 @@ FPtrList *f_ptrlist_new(void)
return new FPtrList();
}

-int f_ptrlist_delete(FPtrList *self, FVisitor *visitor)
+int f_ptrlist_delete(FPtrList *self)
{
ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));

-       self->clear(/* visitor */);
+       self->clear();
delete self;
return 0;
}
diff --git a/lib/libpacman/util/fptrlist.h b/lib/libpacman/util/fptrlist.h
index f3b456f..ef95ab9 100644
--- a/lib/libpacman/util/fptrlist.h
+++ b/lib/libpacman/util/fptrlist.h
@@ -26,7 +26,6 @@

#include "stdbool.h"

-#include "util/fcallback.h"
#include "util/flist.h"

#ifndef __cplusplus
@@ -40,9 +39,7 @@ typedef FPtrListItem FPtrListIterator;
extern "C" {
#endif /* __cplusplus */

-#define _FREELIST(p, f) do { if(p) { FVisitor visitor = { (FVisitorFunc)f, 
NULL }; f_ptrlist_delete(p, &visitor); p = NULL; } } while(0)
-
-#define FREELIST(p) _FREELIST(p, free)
+#define FREELIST(p) do { if(p) { f_ptrlist_delete(p); p = NULL; } } while(0)

FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn);
bool _pacman_list_remove(FPtrList *haystack, void *needle, _pacman_fn_cmp fn, 
void **data);
@@ -54,7 +51,7 @@ FPtrListIterator *f_ptrlistitem_next(FPtrListIterator *self);
size_t f_ptrlistiterator_count(const FPtrListIterator *self, const 
FPtrListIterator *to);

FPtrList *f_ptrlist_new(void);
-int f_ptrlist_delete(FPtrList *list, FVisitor *visitor);
+int f_ptrlist_delete(FPtrList *list);

FPtrList *f_ptrlist_add(FPtrList *list, void *data);
size_t f_ptrlist_count(const FPtrList *self);
diff --git a/src/pacman-g2/ps.c b/src/pacman-g2/ps.c
index d00e599..864ca9c 100644
--- a/src/pacman-g2/ps.c
+++ b/src/pacman-g2/ps.c
@@ -236,7 +236,7 @@ int pspkg(int countonly)
}
count++;
}
-       f_ptrlist_delete(ret, NULL);
+       f_ptrlist_delete(ret);

end_lsof(fpout, pid);

diff --git a/src/pacman-g2/sync.c b/src/pacman-g2/sync.c
index 78b0925..5ed96c0 100644
--- a/src/pacman-g2/sync.c
+++ b/src/pacman-g2/sync.c
@@ -214,7 +214,7 @@ static int sync_list(FStringList *targets)

if(db == NULL) {
ERR(NL, _("repository \"%s\" was not found.\n"), (char *)list_data(i));
-                               f_ptrlist_delete(ls, NULL);
+                               f_ptrlist_delete(ls);
return 1;
}

@@ -237,7 +237,7 @@ static int sync_list(FStringList *targets)
}
}
if(targets) {
-               f_ptrlist_delete(ls, NULL);
+               f_ptrlist_delete(ls);
}
return 0;
}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to