Il 18/03/2014 19:40, Markus Armbruster ha scritto:
> +void *
> +g_malloc (size_t n_bytes)
> +{
> + void *mem;
> + __coverity_negative_sink__((ssize_t) n_bytes);
> + mem = malloc(n_bytes == 0 ? 1 : n_bytes);
> + if (!mem) __coverity_panic__ ();
> + return mem;
> +}
This isn't quite honest: g_malloc(0) yields NULL. Same for the other
allocation functions.
Oh, I didn't know that.
It probably would make static analysis a bit less powerful or will
return more false positives. The NULL return for realloc (in the "free"
case) already causes some. So I'm undecided between a more correct
model and a more selective one (with a fat comment).
Paolo