diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-09-08 16:33:29 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-09-08 16:33:29 -0400 |
| commit | 717caf4e287b7789e9dc2fccf7213d344ee69c21 (patch) | |
| tree | 4fb7f311ec9de6afa274e6c13086d44f98ae6da6 /src | |
| parent | 1ba33e37efaa0545f5d08b6f0e8a5e73ef9bfc63 (diff) | |
| download | slapi-nis-717caf4e287b7789e9dc2fccf7213d344ee69c21.tar.gz slapi-nis-717caf4e287b7789e9dc2fccf7213d344ee69c21.tar.xz slapi-nis-717caf4e287b7789e9dc2fccf7213d344ee69c21.zip | |
- fixup some of the logic where we check for duplicates in the
ref_attr_list
Diffstat (limited to 'src')
| -rw-r--r-- | src/format.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/format.c b/src/format.c index 36a6c42..ff9ce8c 100644 --- a/src/format.c +++ b/src/format.c @@ -224,6 +224,30 @@ format_dup_ref_attr_list(struct format_ref_attr_list **list) return ret; } +static struct format_ref_attr_list * +format_find_ref_attr_list(struct format_ref_attr_list **list, + const char *group, const char *set, + const char **names) +{ + unsigned int i; + int j; + const char *attribute; + for (i = 0; (list != NULL) && (list[i] != NULL); i++) { + for (j = 0; names[j] != NULL; j++) { + if (j < list[i]->n_links) { + attribute = list[i]->links[j].attribute; + if (strcmp(names[j], attribute) != 0) { + break; + } + } + } + if ((j == list[i]->n_links) && (names[j] == NULL)) { + return list[i]; + } + } + return NULL; +} + static struct format_ref_attr_list ** format_add_ref_attr_list(struct format_ref_attr_list ***list, const char *group, const char *set, @@ -233,17 +257,10 @@ format_add_ref_attr_list(struct format_ref_attr_list ***list, struct slapi_dn **dn_list; unsigned int i; int j; + if (format_find_ref_attr_list(*list, group, set, names) != NULL) { + return *list; + } for (i = 0; (list != NULL) && (list[i] != NULL); i++) { - for (j = 0; names[j] != NULL; j++) { - if ((j < (*list)[i]->n_links) && - (strcmp(names[j], - (*list)[i]->links[j].attribute) == 0)){ - break; - } - } - if (names[j] == NULL) { - return *list; - } continue; } ret = malloc((i + 2) * sizeof(struct format_ref_attr_list*)); |
