[RFC PATCH 1/4] Integrate UCM basic functions into alsa card module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, 2012-06-11 at 18:28 +0800, Feng Wei wrote:
[snip]
> >> +static int ucm_port_contain(const char *port_name, const char *dev_name) {
> >> +    int ret=0;
> >> +    char *r;
> >> +    const char *state=NULL;
> >> +
> >> +    if (!port_name || !dev_name)
> >> +        return FALSE;
> >> +
> >> +    while ((r = pa_split(port_name, "+", &state))) {
> >> +        if (!strcmp(r, dev_name)) {
> >> +            pa_xfree(r);
> >> +            ret = 1;
> >> +            break;
> >> +        }
> >> +        pa_xfree(r);
> >> +    }
> >> +    return ret;
> >> +}
> >
> > Better to use strstr() here. Avoids some unnecessary allocation +
> > deallocation.
> Is it possible that we have sub string matching in error?

I'm attaching a patch snippet of something that might be useful instead.
Untested, but should work -- if it looks fine, I can commit this.

One comment that I missed, I think -- I see that you've called
structures pa_alsa_ucm_* and functions pa_ucm_*. Could you make them all
pa_alsa_ucm_*?

Thanks for all the efforts,
Arun
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pa_split_in_place.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20120613/0877d1ab/attachment.bin>


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux