summaryrefslogtreecommitdiffstats
path: root/cmd-source-file.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-02-08 18:29:32 +0000
committerTiago Cunha <tcunha@gmx.com>2010-02-08 18:29:32 +0000
commit36a80b2cd639fc82b8fc3d8c3672cc88ae00f1ac (patch)
tree433a4b1783d04085f0859b4fc6d7550ab7dd5913 /cmd-source-file.c
parentc6ba78137977bd7a447fd5f97b205544c2b41505 (diff)
Sync OpenBSD patchset 640:
Use the array.h code for the causes list.
Diffstat (limited to 'cmd-source-file.c')
-rw-r--r--cmd-source-file.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/cmd-source-file.c b/cmd-source-file.c
index c97eff63..a21ae498 100644
--- a/cmd-source-file.c
+++ b/cmd-source-file.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-source-file.c,v 1.12 2010-02-08 18:10:07 tcunha Exp $ */
+/* $Id: cmd-source-file.c,v 1.13 2010-02-08 18:29:32 tcunha Exp $ */
/*
* Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
@@ -89,18 +89,18 @@ int
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_source_file_data *data = self->data;
- char **causes;
- u_int i, ncauses;
-
- causes = NULL;
- ncauses = 0;
-
- if (load_cfg(data->path, ctx, &ncauses, &causes) != 0) {
- for (i = 0; i < ncauses; i++) {
- ctx->print(ctx, "%s", causes[i]);
- xfree(causes[i]);
+ struct causelist causes;
+ char *cause;
+ u_int i;
+
+ ARRAY_INIT(&causes);
+ if (load_cfg(data->path, ctx, &causes) != 0) {
+ for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
+ cause = ARRAY_ITEM(&causes, i);
+ ctx->print(ctx, "%s", cause);
+ xfree(cause);
}
- xfree(causes);
+ ARRAY_FREE(&causes);
}
return (0);