/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "squid.h"
#include "compat/xalloc.h"
-#include "profiler/Profiler.h"
#if XMALLOC_STATISTICS
#define XMS_DBG_MAXSIZE (1024*1024)
void *
xcalloc(size_t n, size_t sz)
{
- PROF_start(xcalloc);
-
if (n < 1)
n = 1;
if (sz < 1)
sz = 1;
- PROF_start(calloc);
void *p = calloc(n, sz);
- PROF_stop(calloc);
- if (p == NULL) {
+ if (!p) {
if (failure_notify) {
static char msg[128];
- snprintf(msg, 128, "xcalloc: Unable to allocate %lu blocks of %lu bytes!\n", (unsigned long)n, (unsigned long)sz);
+ snprintf(msg, 128, "xcalloc: Unable to allocate %" PRIuSIZE " blocks of %" PRIuSIZE " bytes!\n", n, sz);
failure_notify(msg);
} else {
perror("xcalloc");
malloc_stat(sz * n);
#endif
- PROF_stop(xcalloc);
return p;
}
void *
xmalloc(size_t sz)
{
- PROF_start(xmalloc);
-
if (sz < 1)
sz = 1;
- PROF_start(malloc);
void *p = malloc(sz);
- PROF_stop(malloc);
- if (p == NULL) {
+ if (!p) {
if (failure_notify) {
static char msg[128];
- snprintf(msg, 128, "xmalloc: Unable to allocate %lu bytes!\n", (unsigned long)sz);
+ snprintf(msg, 128, "xmalloc: Unable to allocate %" PRIuSIZE " bytes!\n", sz);
failure_notify(msg);
} else {
perror("malloc");
malloc_stat(sz);
#endif
- PROF_stop(xmalloc);
return (p);
}
void *
xrealloc(void *s, size_t sz)
{
- PROF_start(xrealloc);
-
if (sz < 1)
sz = 1;
- PROF_start(realloc);
void *p= realloc(s, sz);
- PROF_stop(realloc);
- if (p == NULL) {
+ if (!p) {
if (failure_notify) {
static char msg[128];
- snprintf(msg, 128, "xrealloc: Unable to reallocate %lu bytes!\n", (unsigned long)sz);
+ snprintf(msg, 128, "xrealloc: Unable to reallocate %" PRIuSIZE " bytes!\n", sz);
failure_notify(msg);
} else {
perror("realloc");
malloc_stat(sz);
#endif
- PROF_stop(xrealloc);
return (p);
}
{
void *s = const_cast<void *>(s_const);
- PROF_start(free_const);
- PROF_start(free);
free(s);
- PROF_stop(free);
- PROF_stop(free_const);
}