In functions vacm_destroy*Entry() the first element check two times, the attached diff simplify code and make checking of first element only once.
-- Oleg Ivanov - Zelax Telecom. [EMAIL PROTECTED]
--- vacm.c.orig 2004-02-11 11:32:00.000000000 +0300
+++ vacm.c 2004-05-28 16:29:36.000000000 +0400
@@ -599,25 +599,20 @@
{
struct vacm_viewEntry *vp, *lastvp = NULL;
- if (viewList && !strcmp(viewList->viewName + 1, viewName)
- && viewList->viewSubtreeLen == viewSubtreeLen
- && !memcmp((char *) viewList->viewSubtree, (char *) viewSubtree,
- viewSubtreeLen * sizeof(oid))) {
- vp = viewList;
- viewList = viewList->next;
- } else {
- for (vp = viewList; vp; vp = vp->next) {
- if (!strcmp(vp->viewName + 1, viewName)
- && vp->viewSubtreeLen == viewSubtreeLen
- && !memcmp((char *) vp->viewSubtree, (char *) viewSubtree,
- viewSubtreeLen * sizeof(oid)))
- break;
- lastvp = vp;
- }
- if (!vp)
- return;
- lastvp->next = vp->next;
+ for (vp = viewList; vp; vp = vp->next) {
+ if (!strcmp(vp->viewName + 1, viewName)
+ && vp->viewSubtreeLen == viewSubtreeLen
+ && !memcmp((char *) vp->viewSubtree, (char *) viewSubtree,
+ viewSubtreeLen * sizeof(oid)))
+ break;
+ lastvp = vp;
}
+ if (!vp)
+ return;
+ if (lastvp)
+ lastvp->next = vp->next;
+ else
+ viewList = viewList->next;
if (vp->reserved)
free(vp->reserved);
free(vp);
@@ -726,21 +721,18 @@
{
struct vacm_groupEntry *vp, *lastvp = NULL;
- if (groupList && groupList->securityModel == securityModel
- && !strcmp(groupList->securityName + 1, securityName)) {
- vp = groupList;
- groupList = groupList->next;
- } else {
- for (vp = groupList; vp; vp = vp->next) {
- if (vp->securityModel == securityModel
- && !strcmp(vp->securityName + 1, securityName))
- break;
- lastvp = vp;
- }
- if (!vp)
- return;
- lastvp->next = vp->next;
+ for (vp = groupList; vp; vp = vp->next) {
+ if (vp->securityModel == securityModel
+ && !strcmp(vp->securityName + 1, securityName))
+ break;
+ lastvp = vp;
}
+ if (!vp)
+ return;
+ if (lastvp)
+ lastvp->next = vp->next;
+ else
+ groupList = groupList->next;
if (vp->reserved)
free(vp->reserved);
free(vp);
@@ -885,25 +877,20 @@
{
struct vacm_accessEntry *vp, *lastvp = NULL;
- if (accessList && accessList->securityModel == securityModel
- && accessList->securityModel == securityModel
- && !strcmp(accessList->groupName + 1, groupName)
- && !strcmp(accessList->contextPrefix + 1, contextPrefix)) {
- vp = accessList;
- accessList = accessList->next;
- } else {
- for (vp = accessList; vp; vp = vp->next) {
- if (vp->securityModel == securityModel
- && vp->securityLevel == securityLevel
- && !strcmp(vp->groupName + 1, groupName)
- && !strcmp(vp->contextPrefix + 1, contextPrefix))
- break;
- lastvp = vp;
- }
- if (!vp)
- return;
- lastvp->next = vp->next;
+ for (vp = accessList; vp; vp = vp->next) {
+ if (vp->securityModel == securityModel
+ && vp->securityLevel == securityLevel
+ && !strcmp(vp->groupName + 1, groupName)
+ && !strcmp(vp->contextPrefix + 1, contextPrefix))
+ break;
+ lastvp = vp;
}
+ if (!vp)
+ return;
+ if (lastvp)
+ lastvp->next = vp->next;
+ else
+ accessList = accessList->next;
if (vp->reserved)
free(vp->reserved);
free(vp);
