octstr_compare

Yury Mikhienko <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Mobicom-Kavkaz
Message-ID <[email protected]>
Hi All!

What are think about the add following code into octstr.c/octstr_compare?

int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
{
    int ret;
    long len;

    seems_valid(ostr1);
    seems_valid(ostr2);

+    if ((ostr1 == NULL) && (ostr2 == NULL))
+       return 0;
        
    if (ostr1->len < ostr2->len)
        len = ostr1->len;
    else
        len = ostr2->len;

    if (len == 0) {
        if (ostr1->len == 0 && ostr2->len > 0)
            return -1;
        if (ostr1->len > 0 && ostr2->len == 0)
            return 1;
        return 0;
    }

    ret = memcmp(ostr1->data, ostr2->data, len);
    if (ret == 0) {
        if (ostr1->len < ostr2->len)
            ret = -1;
        else if (ostr1->len > ostr2->len)
            ret = 1;
    }
    return ret;
}


-- 
 
Best regards,
Yury Mikhienko.
IT ERP group head, ZAO "Mobikom-Kavkaz"
tel: (8632) 704188
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.