assert in malloc.c:383
Bogdan Vacaliuc
bvacaliuc at ngit.com
Fri Jan 14 14:51:11 UTC 2005
Karel Gardas wrote:
> The problematic code is a part of free function and it looks:
>
> 380 status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr );
> 381 if ( status != RTEMS_SUCCESSFUL ) {
> 382 errno = EINVAL;
> 383 assert( 0 );
> 384 }
>
> my question is: how to prevent it? Is assert on this place really needed,
> especially when I consider that you set errno on this place. What does
In regards to your question on whether assert() is really needed, please
remember that assert() is typically (always!) a conditional macro, whose
code is eliminated by the definition of _NDEBUG. Its operation is generally
a system halt with diagnostic output to enable you to identify the problem
quickly.
Code written with assert() should not *rely* on assert() as the error
handling method; it is not that. It is a *debugging* tool.
Best Regards,
-bogdan
More information about the users
mailing list