mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 09:48:29 +00:00
Fix bugs and make code tinier
- Fixed bug where stdio eof wasn't being sticky - Fixed bug where fseeko() wasn't clearing eof state - Removed assert() usage from libc favoring _unassert() / _npassert()
This commit is contained in:
parent
9b7c8db846
commit
d5910e2673
115 changed files with 510 additions and 290 deletions
|
@ -145,11 +145,11 @@ static void __memlog_update(void *p2, void *p) {
|
|||
__memlog.usage += n - __memlog.allocs.p[i].size;
|
||||
__memlog.allocs.p[i].addr = p2;
|
||||
__memlog.allocs.p[i].size = n;
|
||||
assert(__memlog.usage >= 0);
|
||||
_unassert(__memlog.usage >= 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert(!"this corruption");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
static void __memlog_log(struct StackFrame *frame, const char *op, void *res,
|
||||
|
@ -169,21 +169,20 @@ static void __memlog_free(void *p) {
|
|||
__memlog.allocs.p[i].addr = 0;
|
||||
__memlog.usage -= __memlog.allocs.p[i].size;
|
||||
__memlog.allocs.f = MIN(__memlog.allocs.f, i);
|
||||
assert(__memlog.usage >= 0);
|
||||
_unassert(__memlog.usage >= 0);
|
||||
} else {
|
||||
kprintf("memlog could not find %p\n", p);
|
||||
assert(!"this corruption");
|
||||
n = -1;
|
||||
notpossible;
|
||||
}
|
||||
__memlog_unlock();
|
||||
assert(__memlog.free);
|
||||
_unassert(__memlog.free);
|
||||
__memlog.free(p);
|
||||
__memlog_log(__builtin_frame_address(0), "free", 0, p, n);
|
||||
}
|
||||
|
||||
static void *__memlog_malloc(size_t n) {
|
||||
void *res;
|
||||
assert(__memlog.malloc);
|
||||
_unassert(__memlog.malloc);
|
||||
if ((res = __memlog.malloc(n))) {
|
||||
__memlog_lock();
|
||||
__memlog_insert(res);
|
||||
|
@ -195,7 +194,7 @@ static void *__memlog_malloc(size_t n) {
|
|||
|
||||
static void *__memlog_calloc(size_t n, size_t z) {
|
||||
void *res;
|
||||
assert(__memlog.calloc);
|
||||
_unassert(__memlog.calloc);
|
||||
if ((res = __memlog.calloc(n, z))) {
|
||||
__memlog_lock();
|
||||
__memlog_insert(res);
|
||||
|
@ -207,7 +206,7 @@ static void *__memlog_calloc(size_t n, size_t z) {
|
|||
|
||||
static void *__memlog_memalign(size_t l, size_t n) {
|
||||
void *res;
|
||||
assert(__memlog.memalign);
|
||||
_unassert(__memlog.memalign);
|
||||
if ((res = __memlog.memalign(l, n))) {
|
||||
__memlog_lock();
|
||||
__memlog_insert(res);
|
||||
|
@ -221,7 +220,7 @@ static void *__memlog_realloc_impl(void *p, size_t n,
|
|||
void *(*f)(void *, size_t),
|
||||
struct StackFrame *frame) {
|
||||
void *res;
|
||||
assert(f);
|
||||
_unassert(f);
|
||||
if ((res = f(p, n))) {
|
||||
__memlog_lock();
|
||||
if (p) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue