[Udpcast] Code Discussion - slice MAGIC

Alain Knaff alain at knaff.lu
Fri Oct 8 19:11:11 CEST 2004


On Friday 08 October 2004 17:27, Saikrishna Dasari wrote:
> Hi Alain,
>
> May I know the logic behind the following statement on receiver side when
> it receives the slices?  what exactly is the use of slice magic?
>
> #define MAGIC 0x41424344
>
> Thanks,
>
> Sai

This is a number that is put into the slice structure in order to
guard against pointer errors (or rather: detect these errors
early). If due to some internal SNAFU, a variable of type slice* would
point to a memory location that was not actually a slice struct, the
error would be detected as soon as the pointer would be used (because
the magic number would not match), rather than to allow it to
propagate further.

Catching such errors early makes it easyer to find the exact place
where the error happens, and makes debugging easyer.

Alain




More information about the Udpcast mailing list