Re: AW: octstr_compare

Yury Mikhienko <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Mobicom-Kavkaz
Message-ID <[email protected]>
On Wed, 10 Mar 2004 11:19:16 +0100
JЖrg Pommnitz <[email protected]> wrote:

> I'm not sure, but I think a NULL octstr would already fail the
> sems_valid test and cause an assertion.
> 
> -----UrsprЭngliche Nachricht-----
> Von: Yury Mikhienko [mailto:[email protected]]
> Gesendet: Mittwoch, 10. MДrz 2004 11:16
> An: [email protected]
> Betreff: octstr_compare
> 
> 
> 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;
> }
> 

But if I use disable_assertion option?

-- 
 
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.