Просмотр исходного кода

u-a: Refactor common code into new alternative_commit_operations_free

Guillem Jover лет назад: 15
Родитель
Сommit
2819f4cc46
1 измененных файлов с 14 добавлено и 11 удалено
  1. 14 11
      utils/update-alternatives.c

+ 14 - 11
utils/update-alternatives.c

@@ -683,11 +683,22 @@ alternative_choices_free(struct alternative *a)
 	}
 }
 
+static void
+alternative_commit_operations_free(struct alternative *a)
+{
+	struct commit_operation *op;
+
+	while (a->commit_ops) {
+		op = a->commit_ops;
+		a->commit_ops = op->next;
+		commit_operation_free(op);
+	}
+}
+
 static void
 alternative_reset(struct alternative *alt)
 {
 	struct slave_link *slave;
-	struct commit_operation *commit_op;
 
 	free(alt->master_link);
 	alt->master_link = NULL;
@@ -697,11 +708,7 @@ alternative_reset(struct alternative *alt)
 		slave_link_free(slave);
 	}
 	alternative_choices_free(alt);
-	while (alt->commit_ops) {
-		commit_op = alt->commit_ops;
-		alt->commit_ops = commit_op->next;
-		commit_operation_free(commit_op);
-	}
+	alternative_commit_operations_free(alt);
 	alt->modified = false;
 }
 
@@ -1544,11 +1551,7 @@ alternative_commit(struct alternative *a)
 		}
 	}
 
-	while (a->commit_ops) {
-		op = a->commit_ops;
-		a->commit_ops = op->next;
-		commit_operation_free(op);
-	}
+	alternative_commit_operations_free(a);
 }
 
 static void