On Montag, 14. März 2022 20:48:47 CET Alex Bennée wrote:
> Markus Armbruster <arm...@redhat.com> writes:
> > g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
> > for two reasons.  One, it catches multiplication overflowing size_t.
> > Two, it returns T * rather than void *, which lets the compiler catch
> > more type errors.
> > 
> > This commit only touches allocations with size arguments of the form
> > sizeof(T).
> > 
> > Patch created mechanically with:
> >     $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \
> >     
> >          --macro-file scripts/cocci-macro-file.h FILES...
> > 
> > Signed-off-by: Markus Armbruster <arm...@redhat.com>
> 
> <snip>
> 
> > --- a/audio/jackaudio.c
> > +++ b/audio/jackaudio.c
> > @@ -97,9 +97,9 @@ static void qjack_buffer_create(QJackBuffer *buffer, int
> > channels, int frames)> 
> >      buffer->used     = 0;
> >      buffer->rptr     = 0;
> >      buffer->wptr     = 0;
> > 
> > -    buffer->data     = g_malloc(channels * sizeof(float *));
> > +    buffer->data     = g_new(float *, channels);
> > 
> >      for (int i = 0; i < channels; ++i) {
> > 
> > -        buffer->data[i] = g_malloc(frames * sizeof(float));
> > +        buffer->data[i] = g_new(float, frames);
> 
> Are these actually buffers of pointers to floats? I guess I leave that
> to the JACK experts...

That's correct. JACK does not use interleaved audio format, it uses separate 
buffers for each audio channel. For the audio stuff of this patch:

Reviewed-by: Christian Schoenebeck <qemu_...@crudebyte.com>

Best regards,
Christian Schoenebeck



Reply via email to