Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
作为个人项目,我想使用 sbrk(不是 mmap)在 C 中编写自己的 malloc 实现。我知道我可以使用 sbrk(0) 来确定数据段的结束,这将标志着我的堆的结束。但是,我想准确地让我的 malloc 返回 NULL,而不是让我的堆溢出到堆栈中。有没有一种方法可以用来确定堆栈在哪里结束以检测这种情况?