I think there are also many cases where we should use either (size_t
and ptrdiff_t) or (intptr_t and uintptr_t), which are not int and
not explicitly sized.  In some of these cases we use
PRUint32/PRInt32 today.  I think we should be using these for things
that correspond to the size or number of allocations (e.g., the size
of an array, a reference count), since they should correspond to the
size of pointers or number of objects that can be allocated on the
architecture in question.  I think doing this avoids some types of
integer overflow bugs.

I'm not sure what the reason to prefer size_t/ptrdiff_t vs.
intptr_t/uintptr_t are (and I hope there aren't any cases where
they're different).  I suppose size_t and ptrdiff_t have been around
longer, but intptr_t and uintptr_t have clearer names.  But I also
tend to think we should only use one set of them.

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                           http://www.mozilla.org/   𝄂
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to