mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
dynarray: Reimplement with nicer semantics
A dynamic array is a nice simple container, but the old interface wasn't quite what I wanted it to be. I like GLib's way of providing the free callback at the container creation time, because that way the free callback doesn't have to be given every time something is removed from the array. The allocation pattern was changed too: instead of increasing the array size always by 25 when the array gets full, the size gets doubled now (the lowest non-zero size is still 25). The array can't store NULL pointers anymore, and pa_dynarray_get() was changed so that it's forbidden to try to access elements outside the valid range. The set of supported operations may seem a bit arbitrary. The operation set is by no means complete at this point. I have included only those operations that are required by the current code and some unpublished code of mine.
This commit is contained in:
parent
d00d5b6611
commit
0f2840f4c6
4 changed files with 65 additions and 71 deletions
|
|
@ -1983,7 +1983,7 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
|
|||
char **sorted_files;
|
||||
struct dirent *de;
|
||||
pa_bool_t failed = FALSE;
|
||||
pa_dynarray *files = pa_dynarray_new();
|
||||
pa_dynarray *files = pa_dynarray_new(NULL);
|
||||
|
||||
while ((de = readdir(d))) {
|
||||
char *extn;
|
||||
|
|
@ -2003,7 +2003,7 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
|
|||
sorted_files = pa_xnew(char*, count);
|
||||
for (i = 0; i < count; ++i)
|
||||
sorted_files[i] = pa_dynarray_get(files, i);
|
||||
pa_dynarray_free(files, NULL);
|
||||
pa_dynarray_free(files);
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
for (unsigned j = 0; j < count; ++j) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue