#159 closed defect (fixed)
psMetadataGetNext() always returns first item on metadata list
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | sys | Version: | unspecified |
| Severity: | normal | Keywords: | |
| Cc: |
Description
psMetadataGetNext() (and ...Prev()) always returns first item on metadata list; the
problem is that they call psListSetIterator() which sets the iterator to the start
of the list.
rel2_2
Change History (5)
comment:1 by , 22 years ago
| Owner: | changed from to |
|---|
comment:2 by , 22 years ago
comment:3 by , 22 years ago
My guess is that you are thinking of tests B and C which read:
psMetadataSetIterator(metadata, 2);
item = psMetadataGetNext(metadata, NULL, 2);
Note that the first "2" is a "where" value (and the API needs to include a "which" too), whereas
the second "2" is a "which" value. The intent of the SDRS (and also I think what it says, if you
read the definitions of "where" and "which") is that the psMetadataSetIterator() call would set
the iterator to the place in the list, and psMetadataGetNext() would then step through the list.
In other words,
int which = 123; which iterator; any should work
psMetadataSetIterator(metadata, which, PS_LIST_HEAD);
while ((m = psMetadataGetNext(metadata, NULL, which)) != NULL) {
printf("%s\n", m->name);
}
should go through every item of the list [note that I've added a "which" to the psMetadataSetIterator
API for clarity; this addition is a neccessary change to the SDRS)
comment:5 by , 21 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Ross notes this function has been dropped, so the bug should be closed.

I'm not sure this is a problem. I ran the tst_psMetadata_05.c test, which tests
the psMetadataGetNext() function, and it appears to return the expected value
according to the API.
I re-read the SDRS for these two functions, and it looks like their arguments
are set up to force the user to define a starting point, which would eliminate
any persistent iterator. Although these functions do appear to return the next
or previous item based on the inputs, maybe the API should be changed to
separate the functionality in terms of getIndex(), getName(), getNext(), and
getPrevious()?