aboutsummaryrefslogtreecommitdiffstats
path: root/src/songvec.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-10-13{dir,song}vec: remove unused *_destroy routinesEric Wong1-11/+0
Blindly destroying these without freeing the underlying elements was a bad idea, always. Our iterators suck less nowadays and we can traverse them and free() each element safely.
2008-10-12{dir,song}vec: fix off-by-one errors in {dir,song}vec_deleteEric Wong1-8/+9
Found by Valgrind while looking for another bug... Hmm.. I should really just make this code generic since they're duplicated...
2008-10-12{dir,song}vec: these structs are constEric Wong1-1/+1
We definitely don't modify them here.
2008-10-12update: fix multiple deletes from *vec iteratorsEric Wong1-1/+5
{song,dir}vec_for_each each failed to gracefully handle deleted files when iterating through. While we were thread-safe, we were not safe within the calling thread. If a callback we passed caused sv->nr to shring, our index would still increment; causing files to stay in the database. A way to test this is to remove 10 or so contiguous songs from a >10 song directory.
2008-10-12directory: always maintain sorted properties vectorsEric Wong1-9/+6
This allows clients to see sorted results while we're updating the DB and removes the need for us to have to sort manually. We'll have to write separate routines for managing stored playlists with songvecs eventually; but that's for another day.
2008-10-12songvec: avoid holding nr_lock during free(3)Eric Wong1-3/+5
We only need to lock sv->nr changes to prevent traversals ( why it's called "nr_lock"). free(3) is a "slow" function on my system; so we can avoid unnecessarily holding a lock long for longer than needed.
2008-10-11songvec: pass const pointersMax Kellermann1-1/+1
Pass const songvec pointers to songvec_find() and songvec_for_each(). [ew: already merged songvec_for_each() cosntification somewhere...]
2008-10-11directory: moved code to database.cMax Kellermann1-1/+2
Taming the directory.c monster, part II: move the database management stuff to database. directory.c should only contain code which works on directory objects.
2008-10-11song: converted typedef Song to struct songMax Kellermann1-11/+11
Again, a data type which can be forward-declared. [ew: * used "struct mpd_song" instead to avoid token duplication (like I did with "struct mpd_tag") as there's no good abbreviation for "song" and identical tokens on the same line don't read well * rewritten using perl -i -p -e 's/\bSong\b/struct mpd_song/g' src/*.[ch] since it was too hard to merge * also, I don't care much for forward declarations ]
2008-10-07directory: use songvec_for_each for iteratorsEric Wong1-31/+0
Get rid of songvec_write so we can enforce proper locking
2008-10-07songvec: lock traversals for thread-safe updates/readsEric Wong1-10/+34
Only one lock is used for all songvec traversals since they're rarely changed. Also, minimize lock time and release it before calling iterator functions since they may block (updateSongInfo => stat/open/seek/read). This lock only protects songvecs (and all of them) during traversals; not the individual song structures themselves.
2008-10-05songvec: add songvec_for_each iteratorEric Wong1-0/+13
This is so we can more consistently deal with locking needed for thread-safety in iterator functions.
2008-10-05song: replace printSong* with song_print_*Eric Wong1-2/+2
This make argument order more consistent for iterators. Additionally, these now return ssize_t results for error checking.
2008-09-28songvec: songvec_delete takes a const Song pointerEric Wong1-1/+1
We don't modify the Song when we delete it
2008-09-28songvec_free => songvec_destroyEric Wong1-1/+1
"free" implies the songvec structure itself is freed, which is not the case.
2008-09-23songvec: avoid free(NULL)Eric Wong1-2/+4
Potentially broken free() implementations don't like it
2008-09-22songvec: remove songvec_pruneEric Wong1-23/+0
Any pruned files will be noticed during update and pruned from the live database, so this inefficient function can go away and never come back.
2008-09-20Replace SongList with struct songvecEric Wong1-0/+121
Our linked-list implementation is wasteful and the SongList isn't modified enough to benefit from being a linked list. So use a more compact array of song pointers which saves ~200K on a library with ~9K songs (on x86-32).