code cleanup
This commit is contained in:
parent
a9540e2c76
commit
beda47fd22
3 changed files with 22 additions and 13 deletions
|
@ -49,7 +49,7 @@ void grp_free(pmgrp_t *grp)
|
||||||
}
|
}
|
||||||
|
|
||||||
FREELIST(grp->packages);
|
FREELIST(grp->packages);
|
||||||
FREE(grp);
|
free(grp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,12 +67,19 @@ typedef struct __pmpkg_t {
|
||||||
unsigned char infolevel;
|
unsigned char infolevel;
|
||||||
} pmpkg_t;
|
} pmpkg_t;
|
||||||
|
|
||||||
#define FREEPKG(p) do { if(p) { pkg_free(p); p = NULL; } } while(0)
|
#define FREEPKG(p) \
|
||||||
|
do { \
|
||||||
#define FREELISTPKGS(p) do {\
|
|
||||||
if(p) { \
|
if(p) { \
|
||||||
PMList *i;\
|
pkg_free(p); \
|
||||||
for(i = p; i; i = i->next) {\
|
p = NULL; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define FREELISTPKGS(p) \
|
||||||
|
do { \
|
||||||
|
if(p) { \
|
||||||
|
PMList *i; \
|
||||||
|
for(i = p; i; i = i->next) { \
|
||||||
FREEPKG(i->data); \
|
FREEPKG(i->data); \
|
||||||
}\
|
}\
|
||||||
FREELIST(p);\
|
FREELIST(p);\
|
||||||
|
|
|
@ -63,14 +63,16 @@ pmsyncpkg_t *sync_new(int type, pmpkg_t *spkg, void *data)
|
||||||
|
|
||||||
void sync_free(pmsyncpkg_t *sync)
|
void sync_free(pmsyncpkg_t *sync)
|
||||||
{
|
{
|
||||||
if(sync) {
|
if(sync == NULL) {
|
||||||
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
return;
|
||||||
FREELISTPKGS(sync->data);
|
|
||||||
} else {
|
|
||||||
FREEPKG(sync->data);
|
|
||||||
}
|
|
||||||
free(sync);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
||||||
|
FREELISTPKGS(sync->data);
|
||||||
|
} else {
|
||||||
|
FREEPKG(sync->data);
|
||||||
|
}
|
||||||
|
free(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test for existance of a package in a PMList* of pmsyncpkg_t*
|
/* Test for existance of a package in a PMList* of pmsyncpkg_t*
|
||||||
|
|
Loading…
Add table
Reference in a new issue