Sync OpenBSD patchset 640:

Use the array.h code for the causes list.
This commit is contained in:
Tiago Cunha
2010-02-08 18:29:32 +00:00
parent c6ba781379
commit 36a80b2cd6
6 changed files with 52 additions and 52 deletions

View File

@ -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;
struct causelist causes;
char *cause;
u_int i;
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]);
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);