{
void *result;
- tor_assert(size < SIZE_T_CEILING);
+ raw_assert(size < SIZE_T_CEILING);
#ifndef MALLOC_ZERO_WORKS
/* Some libc mallocs don't work when size==0. Override them. */
if (PREDICT_UNLIKELY(result == NULL)) {
/* LCOV_EXCL_START */
- log_err(LD_MM,"Out of memory on malloc(). Dying.");
/* If these functions die within a worker process, they won't call
* spawn_exit, but that's ok, since the parent will run out of memory soon
* anyway. */
- exit(1); // exit ok: alloc failed.
+ raw_assert_unreached_msg("Out of memory on malloc(). Dying.");
/* LCOV_EXCL_STOP */
}
return result;
void *
tor_calloc_(size_t nmemb, size_t size)
{
- tor_assert(size_mul_check(nmemb, size));
+ raw_assert(size_mul_check(nmemb, size));
return tor_malloc_zero_((nmemb * size));
}
{
void *result;
- tor_assert(size < SIZE_T_CEILING);
+ raw_assert(size < SIZE_T_CEILING);
#ifndef MALLOC_ZERO_WORKS
/* Some libc mallocs don't work when size==0. Override them. */
if (PREDICT_UNLIKELY(result == NULL)) {
/* LCOV_EXCL_START */
- log_err(LD_MM,"Out of memory on realloc(). Dying.");
- exit(1); // exit ok: alloc failed.
+ raw_assert_unreached_msg("Out of memory on realloc(). Dying.");
/* LCOV_EXCL_STOP */
}
return result;
{
/* XXXX we can make this return 0, but we would need to check all the
* reallocarray users. */
- tor_assert(size_mul_check(sz1, sz2));
+ raw_assert(size_mul_check(sz1, sz2));
return tor_realloc(ptr, (sz1 * sz2));
}
tor_strdup_(const char *s)
{
char *duplicate;
- tor_assert(s);
+ raw_assert(s);
duplicate = raw_strdup(s);
if (PREDICT_UNLIKELY(duplicate == NULL)) {
/* LCOV_EXCL_START */
- log_err(LD_MM,"Out of memory on strdup(). Dying.");
- exit(1); // exit ok: alloc failed.
+ raw_assert_unreached_msg("Out of memory on strdup(). Dying.");
/* LCOV_EXCL_STOP */
}
return duplicate;
tor_strndup_(const char *s, size_t n)
{
char *duplicate;
- tor_assert(s);
- tor_assert(n < SIZE_T_CEILING);
+ raw_assert(s);
+ raw_assert(n < SIZE_T_CEILING);
duplicate = tor_malloc_((n+1));
/* Performance note: Ordinarily we prefer strlcpy to strncpy. But
* this function gets called a whole lot, and platform strncpy is
tor_memdup_(const void *mem, size_t len)
{
char *duplicate;
- tor_assert(len < SIZE_T_CEILING);
- tor_assert(mem);
+ raw_assert(len < SIZE_T_CEILING);
+ raw_assert(mem);
duplicate = tor_malloc_(len);
memcpy(duplicate, mem, len);
return duplicate;
tor_memdup_nulterm_(const void *mem, size_t len)
{
char *duplicate;
- tor_assert(len < SIZE_T_CEILING+1);
- tor_assert(mem);
+ raw_assert(len < SIZE_T_CEILING+1);
+ raw_assert(mem);
duplicate = tor_malloc_(len+1);
memcpy(duplicate, mem, len);
duplicate[len] = '\0';