]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - compat/xalloc.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / compat / xalloc.cc
index 9814e35119dd61f33b6d39bb2aa386eab65a9b21..812c5e3193995706c4624bc29d2f82a964402e49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2017 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.
@@ -8,7 +8,6 @@
 
 #include "squid.h"
 #include "compat/xalloc.h"
-#include "profiler/Profiler.h"
 
 #if XMALLOC_STATISTICS
 #define XMS_DBG_MAXSIZE   (1024*1024)
@@ -71,19 +70,15 @@ malloc_statistics(void (*func) (int, int, int, void *), void *data)
 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 %" PRIuSIZE " blocks of %" PRIuSIZE " bytes!\n", n, sz);
@@ -98,23 +93,18 @@ xcalloc(size_t n, size_t sz)
     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 %" PRIuSIZE " bytes!\n", sz);
@@ -129,23 +119,18 @@ xmalloc(size_t sz)
     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 %" PRIuSIZE " bytes!\n", sz);
@@ -161,7 +146,6 @@ xrealloc(void *s, size_t sz)
     malloc_stat(sz);
 #endif
 
-    PROF_stop(xrealloc);
     return (p);
 }
 
@@ -170,10 +154,6 @@ free_const(const void *s_const)
 {
     void *s = const_cast<void *>(s_const);
 
-    PROF_start(free_const);
-    PROF_start(free);
     free(s);
-    PROF_stop(free);
-    PROF_stop(free_const);
 }