Is ((void *) -1) a valid address?

前端 未结 3 1137
忘了有多久
忘了有多久 2020-11-27 05:53

Verbatim from Linux\' man shmat:

RETURN VALUE

[...] on error (void *) -1 is returned, and errno is set to indicate the cause of t

3条回答
  •  庸人自扰
    2020-11-27 06:36

    0xffffffff is technically a valid address in a 32 bit environment but on most operating systems (Certainly Linux/Windows) will be in the reserved kernel part of the address space. That means that in user mode processes it's safe to use it as a error code since no user mode allocation function would return this as a usable address.

提交回复
热议问题