mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
fix pa_memchunk_make_writable(), make memchunk functions return the memchunk they modify
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1728 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
bfe69cebf3
commit
c2e4328c53
2 changed files with 11 additions and 6 deletions
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#include "memchunk.h"
|
#include "memchunk.h"
|
||||||
|
|
||||||
void pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
|
pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
|
||||||
pa_memblock *n;
|
pa_memblock *n;
|
||||||
size_t l;
|
size_t l;
|
||||||
void *tdata, *sdata;
|
void *tdata, *sdata;
|
||||||
|
|
@ -42,9 +42,10 @@ void pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
|
||||||
assert(c);
|
assert(c);
|
||||||
assert(c->memblock);
|
assert(c->memblock);
|
||||||
|
|
||||||
if (pa_memblock_is_read_only(c->memblock) &&
|
if (pa_memblock_ref_is_one(c->memblock) &&
|
||||||
|
!pa_memblock_is_read_only(c->memblock) &&
|
||||||
pa_memblock_get_length(c->memblock) >= c->index+min)
|
pa_memblock_get_length(c->memblock) >= c->index+min)
|
||||||
return;
|
return c;
|
||||||
|
|
||||||
l = c->length;
|
l = c->length;
|
||||||
if (l < min)
|
if (l < min)
|
||||||
|
|
@ -59,11 +60,15 @@ void pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
|
||||||
pa_memblock_unref(c->memblock);
|
pa_memblock_unref(c->memblock);
|
||||||
c->memblock = n;
|
c->memblock = n;
|
||||||
c->index = 0;
|
c->index = 0;
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_memchunk_reset(pa_memchunk *c) {
|
pa_memchunk* pa_memchunk_reset(pa_memchunk *c) {
|
||||||
assert(c);
|
assert(c);
|
||||||
|
|
||||||
c->memblock = NULL;
|
c->memblock = NULL;
|
||||||
c->length = c->index = 0;
|
c->length = c->index = 0;
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ typedef struct pa_memchunk {
|
||||||
/* Make a memchunk writable, i.e. make sure that the caller may have
|
/* Make a memchunk writable, i.e. make sure that the caller may have
|
||||||
* exclusive access to the memblock and it is not read_only. If needed
|
* exclusive access to the memblock and it is not read_only. If needed
|
||||||
* the memblock in the structure is replaced by a copy. */
|
* the memblock in the structure is replaced by a copy. */
|
||||||
void pa_memchunk_make_writable(pa_memchunk *c, size_t min);
|
pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min);
|
||||||
|
|
||||||
/* Invalidate a memchunk. This does not free the cotaining memblock,
|
/* Invalidate a memchunk. This does not free the cotaining memblock,
|
||||||
* but sets all members to zero. */
|
* but sets all members to zero. */
|
||||||
void pa_memchunk_reset(pa_memchunk *c);
|
pa_memchunk* pa_memchunk_reset(pa_memchunk *c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue