Re: svn commit: r1917266 - in /apr/apr/trunk: buffer/apr_buffer.c include/apr_buffer.h test/testbuffer.c

Yann Ylavic <[email protected]>
Newsgroups gmane.comp.apache.apr.devel
Message-ID <CAKQ1sVO5_G-pu0=Qd-JC636CT+bKS942KFpxc+W9LFPdae-0ig@mail.gmail.com>
On Wed, Apr 24, 2024 at 3:03 PM Yann Ylavic <[email protected]> wrote:
>
> APR_DECLARE(int) apr_buffer_cmp(const apr_buffer_t *src,
>                                 const apr_buffer_t *dst)
> {
>     apr_size_t slen, dlen;
>
>     if (!src) {
>         return dst ? 1 : 0;
>     }
>     if (!dst) {
>         return -1;
>     }
>     if (src->size != dst->size) {
>         return src->size < dst->size ? -1 : 1;
>     }
>
>     return memcmp(src->d.mem, dst->d.mem, slen);
> }
>
> Though I still don't think that we should handle NULLs here (let it crash..).

I meant:

APR_DECLARE(int) apr_buffer_cmp(const apr_buffer_t *src,
                                const apr_buffer_t *dst)
{
    apr_size_t slen, dlen;

    if (!src.d.mem) {
        return dst.d.mem ? 1 : 0;
    }
    if (!dst.d.mem) {
        return -1;
    }
    if (src->size != dst->size) {
        return src->size < dst->size ? -1 : 1;
    }

    return memcmp(src->d.mem, dst->d.mem, slen);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.