Index

size_t

Random C fact of the day: I though that size_t was a built-in type, because that’s what the operator sizeof is supposed to return. Roman Ligasor –a co-worker– proved me wrong. It turns out that it’s defined in the header stddef.h. C is a minimalist language, why define a built-in type that will just be an alias to another built-in type?

Without transition: According to the CERT Secure Coding Standards, one should use size_t instead of integer types for object sizes.

Don’t:

int copy(void *dst, const void *src, int size);

Do:

size_t copy(void *dst, const void *src, size_t size);