AW: AW: octstr_compare

Jorg Pommnitz <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
> But if I use disable_assertion option?

If you need this at all, then you should handle the NULL case before the
seems_valid tests. And you should cover all the cases, e.g.
(octstr1 == NULL) && (octstr2 == NULL) -> true
(octstr1 == NULL) && (octstr2 != NULL) -> false
(octstr1 != NULL) && (octstr2 == NULL) -> false

Than do the seems_valid tests and the normal code.

But seriously, I doubt that this is a good idea. Just don't compare invalid
octstr
or, if you really need this, than write a wrapper:

int
octstr_compare_null_safe (octstr1, octstr2)
{
  if (!octsr1 && !octsr2)
	return 1;
  else if ((!octsr1 && octstr2) || (octstr1 && !octstr2))
	return 0;
  else
     return octstr_compare (octstr1, octstr2);
}

This way you do not pollute the general code.

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