memory - 如何判断哪些对 malloc 的调用失败?
问题描述
我这里的内存是一个 32 字节的数组,地址从 0 到 31,当且仅当内存中有 n+1 个连续的可用字节时,对 malloc(n) 的调用才会成功
1: malloc(2)
2: free(1)
3: malloc(14)
4: free(1)
5: malloc(2)
6: free(1)
7: malloc(11)
8: malloc(6)
9: malloc(11)
10: free(20)
11: malloc(6)
12: malloc(14)
13: malloc(13)
14: malloc(1)
15: free(27)
16: malloc(2)
17: malloc(5)
18: malloc(1)
19: free(27)
20: free(20)
我主要是寻求帮助以了解如何判断哪个失败而不是哪个失败,如果这是有道理的,谢谢!
解决方案
推荐阅读
- reactjs - 如何在 React 中测试上下文?
- tcp - 即使发送和接收 TCP 段,是否可以不设置同步控制位?为什么?请举例
- consul - 使用脚本的领事健康检查未验证
- reactjs - 未选中复选框时,React-Final-Form 不会重新运行验证
- javascript - 在 Javascript 中从数组中搜索和检索匹配数据
- firebase - 如何在 REST API 中获取 firebase oobcode
- javascript - SqlLite MAX() 得到一列错误
- extjs - Extjs:未捕获的 TypeError:无法读取 null 的属性“removeAttribute”
- python - 如何在python中运行powershell脚本
- python - 使用外键提交 Django 表单