Skip to content

Change size-related usages of int -> size_t #29

@apsun

Description

@apsun

Arguments for doing this:

  • Casting sizeof() everywhere is ugly (counterpoint: maybe this means we should make a #define isizeof(x) ((int)sizeof(x)) macro instead?
  • Improve standards conformance of libc string functions (counterpoint: we use char instead of int and some non-standard function signatures already)
  • Compiler builtins assume memcpy/memmove/memset take size_t and synthesize calls accordingly, so on the off chance we ever want to support 64-bit, we'll get mismatched argument types (although I guess since x64 uses fastcall, it probably won't explode immediately?)
  • malloc() and friends are odd-ones-out (since myalloc was originally an external project)
  • I think getting the OS to compile with -Wconversion would be pretty cool, and using int makes it a lot harder

I don't want to change the return type of syscalls (for uniformity/OCD reasons); this effectively means that all syscalls are still limited to reading 2GB at a time. Which is fine; we need to limit the range to half of size_t anyways since the return value needs to encode an error bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions