IMHO, function is_big_endian and l2b could be replaced with htonl and its family.
And it seems that this project doesn't check the endian in some places. For example,
https://github.com/ipipdotnet/ipdb-c/blob/master/ipdb.c#L63
return l2b((unsigned int) tar);
Should we check the endian before calling l2c? Maybe better to use htonl?
https://github.com/ipipdotnet/ipdb-c/blob/master/ipdb.c#L146
int size = (reader->data[resolved] << 8) | reader->data[resolved + 2];
Is this line incorrect under big endian? I guess it could be replaced with htons. BTW, it should be resolved + 1, not resolved + 2.
IMHO, function
is_big_endianandl2bcould be replaced withhtonland its family.And it seems that this project doesn't check the endian in some places. For example,
https://github.com/ipipdotnet/ipdb-c/blob/master/ipdb.c#L63
Should we check the endian before calling
l2c? Maybe better to usehtonl?https://github.com/ipipdotnet/ipdb-c/blob/master/ipdb.c#L146
Is this line incorrect under big endian? I guess it could be replaced with
htons. BTW, it should beresolved + 1, notresolved + 2.