-/* $OpenBSD: malloc.c,v 1.221 2017/04/13 18:32:55 otto Exp $ */
+/* $OpenBSD: malloc.c,v 1.222 2017/04/17 16:36:35 otto Exp $ */
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
}
static inline
-struct dir_info *getpool(void)
+struct dir_info *getpool(void)
{
if (!mopts.malloc_mt)
return mopts.malloc_pool[0];
/* Adjust to the real offset of that chunk */
k += (lp - bp->bits) * MALLOC_BITS;
-
+
if (mopts.chunk_canaries)
bp->bits[bp->offset + k] = size;
}
_MALLOC_LOCK(d->mutex);
d->func = "malloc";
-
+
if (d->active++) {
malloc_recurse(d);
return NULL;
if (r != NULL)
break;
}
- }
+ }
if (r == NULL)
wrterror(pool, "bogus pointer (double free?) %p", p);
}
if (sz <= MALLOC_MAXCHUNK) {
if (mopts.chunk_canaries) {
struct chunk_info *info =
- (struct chunk_info *)r->size;
+ (struct chunk_info *)r->size;
uint32_t chunknum =
- find_chunknum(pool, r, p, 0);
+ find_chunknum(pool, r, p, 0);
if (info->bits[info->offset + chunknum] <
argsz)
" < %zu",
info->bits[info->offset + chunknum],
argsz);
- }
+ }
} else if (sz - mopts.malloc_guard < argsz)
wrterror(pool, "recorded old size %zu < %zu",
sz - mopts.malloc_guard, argsz);
void *q, *ret;
int i;
uint32_t chunknum;
-
+
pool = argpool;
if (p == NULL)
if (r != NULL)
break;
}
- }
+ }
if (r == NULL)
wrterror(pool, "bogus pointer (double free?) %p", p);
}
int i;
pool = argpool;
-
+
if (p == NULL)
return omalloc(pool, newsize, 1, f);
if (r == NULL)
wrterror(pool, "bogus pointer (double free?) %p", p);
}
-
+
REALSIZE(sz, r);
if (sz <= MALLOC_MAXCHUNK) {
if (mopts.chunk_canaries) {
return NULL;
}
oldsize = oldnmemb * size;
-
+
/*
* Don't bother too much if we're shrinking just a bit,
* we do not shrink for series of small steps, oh well.
_MALLOC_LOCK(d->mutex);
d->func = "recallocarray";
-
+
if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
newnmemb > 0 && SIZE_MAX / newnmemb < size) {
_MALLOC_UNLOCK(d->mutex);