trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1166280 - in /trafficserver/traffic/trunk: mgmt/ mgmt/api/remote/ mgmt/preparse/ proxy/ proxy/congest/ proxy/hdrs/ proxy/http/ proxy/http/remap/ proxy/logging/
Date Wed, 07 Sep 2011 17:28:11 GMT
Author: zwoop
Date: Wed Sep  7 17:28:10 2011
New Revision: 1166280

URL: http://svn.apache.org/viewvc?rev=1166280&view=rev
Log:
TS-567 Sixth set of xmalloc -> ats_malloc conversion

Modified:
    trafficserver/traffic/trunk/mgmt/Alarms.cc
    trafficserver/traffic/trunk/mgmt/BaseManager.cc
    trafficserver/traffic/trunk/mgmt/FileManager.cc
    trafficserver/traffic/trunk/mgmt/ProcessManager.cc
    trafficserver/traffic/trunk/mgmt/Rollback.cc
    trafficserver/traffic/trunk/mgmt/Rollback.h
    trafficserver/traffic/trunk/mgmt/api/remote/NetworkUtilsRemote.cc
    trafficserver/traffic/trunk/mgmt/preparse/RemapReadConfig.cc
    trafficserver/traffic/trunk/proxy/InkXml.cc
    trafficserver/traffic/trunk/proxy/Plugin.cc
    trafficserver/traffic/trunk/proxy/ProxyConfig.cc
    trafficserver/traffic/trunk/proxy/StatPages.cc
    trafficserver/traffic/trunk/proxy/StatSystem.cc
    trafficserver/traffic/trunk/proxy/Stuffer.cc
    trafficserver/traffic/trunk/proxy/congest/MT_hashtable.h
    trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc
    trafficserver/traffic/trunk/proxy/hdrs/HdrTest.cc
    trafficserver/traffic/trunk/proxy/http/HttpMessageBody.cc
    trafficserver/traffic/trunk/proxy/http/remap/StringHash.cc
    trafficserver/traffic/trunk/proxy/logging/LogFilter.cc

Modified: trafficserver/traffic/trunk/mgmt/Alarms.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/Alarms.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/Alarms.cc (original)
+++ trafficserver/traffic/trunk/mgmt/Alarms.cc Wed Sep  7 17:28:10 2011
@@ -317,7 +317,7 @@ Alarms::signalAlarm(alarm_t a, const cha
     }
   }
 
-  ink_assert((atmp = (Alarm *) xmalloc(sizeof(Alarm))));
+  atmp = (Alarm *)ats_malloc(sizeof(Alarm));
   atmp->type = a;
   atmp->linger = true;
   atmp->seen = true;
@@ -356,21 +356,15 @@ ALARM_REPEAT:
   if (atmp->description)
     xfree(atmp->description);
   const size_t atmp_desc_size = sizeof(char) * (strlen(desc) + 1);
-  ink_assert(atmp->description = (char *) xmalloc(atmp_desc_size));
+  atmp->description = (char *)ats_malloc(atmp_desc_size);
   ink_strncpy(atmp->description, desc, atmp_desc_size);
-
   ink_mutex_release(&mutex);
 
 #if defined(MGMT_API)
   if (mgmt_alarm_event_q) {
     // ADDED CODE here is where we Add to the queue of alarms one more
-    EventNoticeForm *new_alarm;
+    EventNoticeForm *new_alarm = (EventNoticeForm *)ats_malloc(sizeof(EventNoticeForm));
 
-    new_alarm = (EventNoticeForm *) xmalloc(sizeof(EventNoticeForm));
-    if (!new_alarm) {
-      Debug("alarm", "can't xmalloc so can't create new alarm struct.\n");
-      return;
-    }
     // allocated space copy over values
     // remember AlarmID start from 0 exactly 1 off but everything else
     // matches
@@ -381,14 +375,11 @@ ALARM_REPEAT:
     new_alarm->seen = atmp->seen;
     if (!atmp->local)
       new_alarm->inet_address = atmp->inet_address;
-    if (!atmp->description)
+    if (!atmp->description) {
       new_alarm->description = NULL;
-    else {
-      new_alarm->description = (char *) xmalloc(sizeof(char) * (strlen(atmp->description)
+ 1));
-      if (!new_alarm->description)
-        new_alarm->description = NULL;  // rather have alarm without description than
drop it completely
-      else
-        strcpy(new_alarm->description, atmp->description);
+    } else {
+      new_alarm->description = (char *)ats_malloc(sizeof(char) * (strlen(atmp->description)
+ 1));
+      strcpy(new_alarm->description, atmp->description);
     }
 
     // new alarm is complete now add it
@@ -407,7 +398,7 @@ ALARM_REPEAT:
     AlarmCallbackFunc func = (AlarmCallbackFunc) ink_hash_table_entry_value(remote_alarms,
entry);
     if (ip) {
       const size_t tmp_size = sizeof(char) * (strlen(ip) + 1);
-      ink_assert((tmp = (char *) xmalloc(tmp_size)));
+      tmp = (char *)ats_malloc(tmp_size);
       ink_strncpy(tmp, ip, tmp_size);
     } else {
       tmp = NULL;
@@ -415,7 +406,7 @@ ALARM_REPEAT:
 
     if (desc) {
       const size_t tmp2_size = sizeof(char) * (strlen(desc) + 1);
-      ink_assert((tmp2 = (char *) xmalloc(tmp2_size)));
+      tmp2 = (char *)ats_malloc(tmp2_size);
       ink_strncpy(tmp2, desc, tmp2_size);
     } else {
       tmp2 = NULL;

Modified: trafficserver/traffic/trunk/mgmt/BaseManager.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/BaseManager.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/BaseManager.cc (original)
+++ trafficserver/traffic/trunk/mgmt/BaseManager.cc Wed Sep  7 17:28:10 2011
@@ -104,12 +104,12 @@ BaseManager::registerMgmtCallback(int ms
     MgmtCallbackList *tmp;
 
     for (tmp = cb_list; tmp->next; tmp = tmp->next);
-    ink_assert(tmp->next = (MgmtCallbackList *) xmalloc(sizeof(MgmtCallbackList)));
+    tmp->next = (MgmtCallbackList *)ats_malloc(sizeof(MgmtCallbackList));
     tmp->next->func = cb;
     tmp->next->opaque_data = opaque_cb_data;
     tmp->next->next = NULL;
   } else {
-    ink_assert(cb_list = (MgmtCallbackList *) xmalloc(sizeof(MgmtCallbackList)));
+    cb_list = (MgmtCallbackList *)ats_malloc(sizeof(MgmtCallbackList));
     cb_list->func = cb;
     cb_list->opaque_data = opaque_cb_data;
     cb_list->next = NULL;
@@ -144,12 +144,12 @@ BaseManager::signalMgmtEntity(int msg_id
   MgmtMessageHdr *mh;
 
   if (data_raw) {
-    mh = (MgmtMessageHdr *) xmalloc(sizeof(MgmtMessageHdr) + data_len);
+    mh = (MgmtMessageHdr *)ats_malloc(sizeof(MgmtMessageHdr) + data_len);
     mh->msg_id = msg_id;
     mh->data_len = data_len;
     memcpy((char *) mh + sizeof(MgmtMessageHdr), data_raw, data_len);
   } else {
-    mh = (MgmtMessageHdr *) xmalloc(sizeof(MgmtMessageHdr));
+    mh = (MgmtMessageHdr *)ats_malloc(sizeof(MgmtMessageHdr));
     mh->msg_id = msg_id;
     mh->data_len = 0;
   }

Modified: trafficserver/traffic/trunk/mgmt/FileManager.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/FileManager.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/FileManager.cc (original)
+++ trafficserver/traffic/trunk/mgmt/FileManager.cc Wed Sep  7 17:28:10 2011
@@ -472,7 +472,7 @@ FileManager::removeSnap(const char *snap
     return SNAP_NOT_FOUND;
   }
 
-  dirEntrySpace = (struct dirent *) xmalloc(sizeof(struct dirent) + pathconf(".", _PC_NAME_MAX)
+ 1);
+  dirEntrySpace = (struct dirent *)ats_malloc(sizeof(struct dirent) + pathconf(".", _PC_NAME_MAX)
+ 1);
 
   while (readdir_r(dir, dirEntrySpace, &entryPtr) == 0) {
     if (!entryPtr)

Modified: trafficserver/traffic/trunk/mgmt/ProcessManager.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/ProcessManager.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/ProcessManager.cc (original)
+++ trafficserver/traffic/trunk/mgmt/ProcessManager.cc Wed Sep  7 17:28:10 2011
@@ -121,7 +121,7 @@ ProcessManager::signalManager(int msg_id
 
   MgmtMessageHdr *mh;
 
-  mh = (MgmtMessageHdr *) xmalloc(sizeof(MgmtMessageHdr) + data_len);
+  mh = (MgmtMessageHdr *)ats_malloc(sizeof(MgmtMessageHdr) + data_len);
   mh->msg_id = msg_id;
   mh->data_len = data_len;
   memcpy((char *) mh + sizeof(MgmtMessageHdr), data_raw, data_len);

Modified: trafficserver/traffic/trunk/mgmt/Rollback.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/Rollback.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/Rollback.cc (original)
+++ trafficserver/traffic/trunk/mgmt/Rollback.cc Wed Sep  7 17:28:10 2011
@@ -162,7 +162,7 @@ root_access_needed(root_access_needed_)
         int fd = openFile(ACTIVE_VERSION, O_RDWR | O_CREAT | O_BINARY);
 #endif
         if (fd >= 0) {
-          alarmMsg = (char *) xmalloc(2048);
+          alarmMsg = (char *)ats_malloc(2048);
           snprintf(alarmMsg, 2048, "Created zero length place holder for config file %s",
fileName);
           mgmt_log(stderr, "[RollBack::Rollback] %s\n", alarmMsg);
           lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_CONFIG_UPDATE_FAILED, alarmMsg);
@@ -223,7 +223,7 @@ root_access_needed(root_access_needed_)
   testFD = openFile(ACTIVE_VERSION, O_RDWR, &testErrno);
   if (testFD < 0) {
     // We failed to open read-write
-    alarmMsg = (char *) xmalloc(2048);
+    alarmMsg = (char *)ats_malloc(2048);
     testFD = openFile(ACTIVE_VERSION, O_RDONLY, &testErrno);
 
     if (testFD < 0) {
@@ -619,7 +619,7 @@ UPDATE_CLEANUP:
   //   to manipulate the disk, the error might not get
   //   written to disk
   if (returnCode != OK_ROLLBACK) {
-    alarmMsg = (char *) xmalloc(1024);
+    alarmMsg = (char *)ats_malloc(1024);
     snprintf(alarmMsg, 1024, "[TrafficManager] Configuration File Update Failed: %s", strerror(errno));
     lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_CONFIG_UPDATE_FAILED, alarmMsg);
     xfree(alarmMsg);
@@ -810,7 +810,7 @@ Rollback::findVersions_ml(ExpandingArray
   // The fun of Solaris - readdir_r requires a buffer passed into it
   //   The man page says this obscene expression gives us the proper
   //     size
-  dirEntrySpace = (struct dirent *) xmalloc(sizeof(struct dirent) + pathconf(".", _PC_NAME_MAX)
+ 1);
+  dirEntrySpace = (struct dirent *)ats_malloc(sizeof(struct dirent) + pathconf(".", _PC_NAME_MAX)
+ 1);
 
   while (readdir_r(dir, dirEntrySpace, &entryPtr) == 0) {
     if (!entryPtr)
@@ -912,7 +912,7 @@ Rollback::extractVersionInfo(ExpandingAr
             versionInfo *verInfo;
 
             if (statFile(version, &fileInfo) >= 0) {
-              verInfo = (versionInfo *) xmalloc(sizeof(versionInfo));
+              verInfo = (versionInfo *)ats_malloc(sizeof(versionInfo));
               verInfo->version = version;
               verInfo->modTime = fileInfo.st_mtime;
               listNames->addEntry((void *) verInfo);

Modified: trafficserver/traffic/trunk/mgmt/Rollback.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/Rollback.h?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/Rollback.h (original)
+++ trafficserver/traffic/trunk/mgmt/Rollback.h Wed Sep  7 17:28:10 2011
@@ -111,7 +111,7 @@ struct versionInfo
 //  findVersions(ExpandingArray* listNames) - scans the config directory for
 //    all versions of the file.  If listNames is not NULL, pointers to versionInfo
 //    structures are inserted into it.  If is the callee's responsibility
-//    to xfree the versionInfo structures.  They are allocated by xmalloc
+//    to xfree the versionInfo structures.  They are allocated by ats_malloc
 //
 // private functions
 //

Modified: trafficserver/traffic/trunk/mgmt/api/remote/NetworkUtilsRemote.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/api/remote/NetworkUtilsRemote.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/api/remote/NetworkUtilsRemote.cc (original)
+++ trafficserver/traffic/trunk/mgmt/api/remote/NetworkUtilsRemote.cc Wed Sep  7 17:28:10
2011
@@ -542,9 +542,7 @@ send_request_name(int fd, OpType op, cha
   }
 
   total_len = SIZE_OP_T + SIZE_LEN + msg_len;
-  msg_buf = (char *) xmalloc(sizeof(char) * total_len);
-  if (!msg_buf)
-    return TS_ERR_SYS_CALL;
+  msg_buf = (char *)ats_malloc(sizeof(char) * total_len);
 
   // fill in op type
   op_t = (int16_t) op;
@@ -591,9 +589,7 @@ send_request_name_value(int fd, OpType o
   val_size = strlen(value);
   msg_len = (SIZE_LEN * 2) + name_len + val_size;
   total_len = SIZE_OP_T + SIZE_LEN + msg_len;
-  msg_buf = (char *) xmalloc(sizeof(char) * (total_len));
-  if (!msg_buf)
-    return TS_ERR_SYS_CALL;
+  msg_buf = (char *)ats_malloc(sizeof(char) * (total_len));
 
   // fill in op type
   op_t = (int16_t) op;
@@ -716,9 +712,7 @@ send_file_write_request(int fd, TSFileNa
 
   msg_len = SIZE_FILE_T + SIZE_VER + SIZE_LEN + size;
   total_len = SIZE_OP_T + SIZE_LEN + msg_len;
-  msg_buf = (char *) xmalloc(sizeof(char) * total_len);
-  if (!msg_buf)
-    return TS_ERR_SYS_CALL;
+  msg_buf = (char *)ats_malloc(sizeof(char) * total_len);
 
   // fill in op type
   op = (int16_t) FILE_WRITE;
@@ -775,9 +769,7 @@ send_record_get_request(int fd, char *re
     return TS_ERR_PARAMS;
 
   total_len = SIZE_OP_T + SIZE_LEN + strlen(rec_name);
-  msg_buf = (char *) xmalloc(sizeof(char) * total_len);
-  if (!msg_buf)
-    return TS_ERR_SYS_CALL;
+  msg_buf = (char *)ats_malloc(sizeof(char) * total_len);
 
   // fill in op type
   op = (int16_t) RECORD_GET;
@@ -998,9 +990,7 @@ send_diags_msg(int fd, TSDiagsT mode, co
   diag_msg_len = (int32_t) strlen(diag_msg);
   msg_len = SIZE_DIAGS_T + SIZE_LEN + diag_msg_len;
   total_len = SIZE_OP_T + SIZE_LEN + msg_len;
-  msg_buf = (char *) xmalloc(sizeof(char) * total_len);
-  if (!msg_buf)
-    return TS_ERR_SYS_CALL;
+  msg_buf = (char *)ats_malloc(sizeof(char) * total_len);
 
   // fill in op type
   op_t = (int16_t) DIAGS;
@@ -1155,11 +1145,7 @@ parse_reply_list(int fd, char **list)
   }
 
   // get the delimited event list string
-  *list = (char *) xmalloc(sizeof(char) * (list_size + 1));
-  if (!(*list)) {
-    return TS_ERR_SYS_CALL;
-  }
-
+  *list = (char *)ats_malloc(sizeof(char) * (list_size + 1));
   amount_read = 0;
   while (amount_read < list_size) {
     ret = read(fd, (void *) *list, list_size - amount_read);
@@ -1284,11 +1270,7 @@ parse_file_read_reply(int fd, int *ver, 
     *text = ink_strndup("", 1);                 // set to empty string
   } else {
     // now we got the size, we can read everything into our msg * then parse it
-    *text = (char *) xmalloc(sizeof(char) * (f_size + 1));
-    if (!(*text)) {
-      return TS_ERR_SYS_CALL;
-    }
-
+    *text = (char *)ats_malloc(sizeof(char) * (f_size + 1));
     amount_read = 0;
     while (amount_read < f_size) {
       ret = read(fd, (void *) *text, f_size - amount_read);
@@ -1411,13 +1393,9 @@ parse_record_get_reply(int fd, TSRecordT
   // get record value
   // allocate correct amount of memory for record value
   if (*rec_type == TS_REC_STRING)
-    *rec_val = xmalloc(sizeof(char) * (rec_size + 1));
+    *rec_val = ats_malloc(sizeof(char) * (rec_size + 1));
   else
-    *rec_val = xmalloc(sizeof(char) * (rec_size));
-
-  if (!(*rec_val)) {
-    return TS_ERR_SYS_CALL;
-  }
+    *rec_val = ats_malloc(sizeof(char) * (rec_size));
 
   amount_read = 0;
   while (amount_read < rec_size) {
@@ -1716,7 +1694,7 @@ parse_event_notification(int fd, TSEvent
   }
 
   // read the event name
-  event_name = (char *) xmalloc(sizeof(char) * (msg_len + 1));
+  event_name = (char *)ats_malloc(sizeof(char) * (msg_len + 1));
   amount_read = 0;
   while (amount_read < msg_len) {
     ret = read(fd, (void *) event_name, msg_len - amount_read);
@@ -1758,7 +1736,7 @@ parse_event_notification(int fd, TSEvent
   }
 
   // read the event description
-  desc = (char *) xmalloc(sizeof(char) * (msg_len + 1));
+  desc = (char *)ats_malloc(sizeof(char) * (msg_len + 1));
   amount_read = 0;
   while (amount_read < msg_len) {
     ret = read(fd, (void *) desc, msg_len - amount_read);

Modified: trafficserver/traffic/trunk/mgmt/preparse/RemapReadConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/preparse/RemapReadConfig.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/preparse/RemapReadConfig.cc (original)
+++ trafficserver/traffic/trunk/mgmt/preparse/RemapReadConfig.cc Wed Sep  7 17:28:10 2011
@@ -170,7 +170,7 @@ parseRemapFile(int fd)
   return NULL;
 
 FAIL:
-  errBuf = (char *) xmalloc(1024);
+  errBuf = (char *)ats_malloc(1024);
   snprintf(errBuf, 1024, "[Entry %d] %s", entry, err);
   return errBuf;
 }

Modified: trafficserver/traffic/trunk/proxy/InkXml.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkXml.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkXml.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkXml.cc Wed Sep  7 17:28:10 2011
@@ -30,14 +30,6 @@
 
 #include "InkXml.h"
 
-/*--- for stand-alone testing
-#define xstrdup strdup
-#define xfree free
-#define xmalloc malloc
-#define NEW(x) x
-#define ink_isspace isspace
----*/
-
 /*-------------------------------------------------------------------------
   InkXmlAttr
   -------------------------------------------------------------------------*/

Modified: trafficserver/traffic/trunk/proxy/Plugin.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Plugin.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Plugin.cc (original)
+++ trafficserver/traffic/trunk/proxy/Plugin.cc Wed Sep  7 17:28:10 2011
@@ -209,7 +209,7 @@ plugin_expand(char *arg)
       if (RecGetRecordFloat(arg, &float_val) != REC_ERR_OKAY) {
         goto not_found;
       }
-      str = (char *) xmalloc(128);
+      str = (char *)ats_malloc(128);
       snprintf(str, 128, "%f", (float) float_val);
       return str;
       break;
@@ -220,7 +220,7 @@ plugin_expand(char *arg)
       if (RecGetRecordInt(arg, &int_val) != REC_ERR_OKAY) {
         goto not_found;
       }
-      str = (char *) xmalloc(128);
+      str = (char *)ats_malloc(128);
       snprintf(str, 128, "%ld", (long int) int_val);
       return str;
       break;
@@ -231,7 +231,7 @@ plugin_expand(char *arg)
       if (RecGetRecordCounter(arg, &count_val) != REC_ERR_OKAY) {
         goto not_found;
       }
-      str = (char *) xmalloc(128);
+      str = (char *)ats_malloc(128);
       snprintf(str, 128, "%ld", (long int) count_val);
       return str;
       break;

Modified: trafficserver/traffic/trunk/proxy/ProxyConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ProxyConfig.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ProxyConfig.cc (original)
+++ trafficserver/traffic/trunk/proxy/ProxyConfig.cc Wed Sep  7 17:28:10 2011
@@ -76,7 +76,7 @@ config_string_alloc_cb(void *data, void 
   int len = -1;
   if (_ss) {
     len = strlen(_ss);
-    _new_value = (char *) xmalloc(len + 1);
+    _new_value = (char *)ats_malloc(len + 1);
     memcpy(_new_value, _ss, len + 1);
   }
 

Modified: trafficserver/traffic/trunk/proxy/StatPages.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/StatPages.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/StatPages.cc (original)
+++ trafficserver/traffic/trunk/proxy/StatPages.cc Wed Sep  7 17:28:10 2011
@@ -59,7 +59,7 @@ StatPagesManager::register_http(const ch
 {
   ink_release_assert(n_stat_pages < MAX_STAT_PAGES);
 
-  stat_pages[n_stat_pages].module = (char *) xmalloc(strlen(module) + 3);
+  stat_pages[n_stat_pages].module = (char *)ats_malloc(strlen(module) + 3);
   snprintf(stat_pages[n_stat_pages].module, strlen(module) + 3, "{%s}", module);
   stat_pages[n_stat_pages++].func = func;
 }
@@ -164,7 +164,7 @@ BaseStatPagesHandler::resp_add(const cha
 
   if (size != response_size) {
     if (!response) {
-      response = (char *) xmalloc(size);
+      response = (char *)ats_malloc(size);
     } else {
       response = (char *) xrealloc(response, size);
     }

Modified: trafficserver/traffic/trunk/proxy/StatSystem.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/StatSystem.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/StatSystem.cc (original)
+++ trafficserver/traffic/trunk/proxy/StatSystem.cc Wed Sep  7 17:28:10 2011
@@ -286,7 +286,7 @@ write_stats_snap()
   {
     int stats_size = MAX_HTTP_TRANS_STATS - NO_HTTP_TRANS_STATS + MAX_DYN_STATS - NO_DYN_STATS;
     int buf_size = sizeof(unsigned int) * 3 + stats_size * (sizeof(global_dyn_stats[0].sum)
+ sizeof(global_dyn_stats[0].count));
-    buf = (char *) xmalloc(buf_size);
+    buf = (char *)ats_malloc(buf_size);
     char *p = buf;
     int i = 0;
 
@@ -413,7 +413,7 @@ stat_callback(Continuation * cont, HTTPH
   int buffer_len = 0;
   int num_prefix_buffer;
 
-  char *var_prefix = (char *) xmalloc((length + 1) * sizeof(char));
+  char *var_prefix = (char *)ats_malloc((length + 1) * sizeof(char));
   memset(var_prefix, 0, ((length + 1) * sizeof(char)));
   strncpy(var_prefix, path, length);
 
@@ -424,7 +424,7 @@ stat_callback(Continuation * cont, HTTPH
   if (!empty) {
 
     result_size = (buffer_len + 16) * sizeof(char);
-    result = (char *) xmalloc(result_size);
+    result = (char *)ats_malloc(result_size);
     memset(result, 0, result_size);
 
     snprintf(result, result_size - 7, "<pre>\n%s", buffer);
@@ -456,22 +456,19 @@ static Action *
 testpage_callback(Continuation * cont, HTTPHdr *)
 {
   const int buf_size = 64000;
-  char *buffer = (char *) xmalloc(buf_size);
+  char *buffer = (char *)ats_malloc(buf_size);
 
-  if (buffer) {
-    for (int i = 0; i < buf_size; i++) {
-      buffer[i] = (char) ('a' + (i % 26));
-    }
-    buffer[buf_size - 1] = '\0';
+  for (int i = 0; i < buf_size; i++) {
+    buffer[i] = (char) ('a' + (i % 26));
+  }
+  buffer[buf_size - 1] = '\0';
 
-    StatPageData data;
+  StatPageData data;
+
+  data.data = buffer;
+  data.length = strlen(buffer);
+  cont->handleEvent(STAT_PAGE_SUCCESS, &data);
 
-    data.data = buffer;
-    data.length = strlen(buffer);
-    cont->handleEvent(STAT_PAGE_SUCCESS, &data);
-  } else {
-    cont->handleEvent(STAT_PAGE_FAILURE, NULL);
-  }
   return ACTION_RESULT_DONE;
 }
 

Modified: trafficserver/traffic/trunk/proxy/Stuffer.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Stuffer.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Stuffer.cc (original)
+++ trafficserver/traffic/trunk/proxy/Stuffer.cc Wed Sep  7 17:28:10 2011
@@ -123,7 +123,7 @@ buildParentIPTable()
 
   stuffer_num_parents = n;
   if (n > 0) {
-    stuffer_parent_ip_array = (uint32_t *) xmalloc(n * sizeof(uint32_t));
+    stuffer_parent_ip_array = (uint32_t *)ats_malloc(n * sizeof(uint32_t));
     memcpy(stuffer_parent_ip_array, &ips[0], n * sizeof(uint32_t));
     for (int i = 0; i < n; i++) {
       unsigned char *str = (unsigned char *) &ips[i];
@@ -260,12 +260,10 @@ Stuffer::mainEvent(int event, void *data
         while ((null_pos = reader->memchr(0)) >= 0) {
           null_pos++;
 
-          char *str = (char *) xmalloc(null_pos);
-          if (str) {
-            reader->read(str, null_pos);
-            stuffer_htable->add(str);
-          } else
-            reader->consume(null_pos);
+          char *str = (char *)ats_malloc(null_pos);
+
+          reader->read(str, null_pos);
+          stuffer_htable->add(str);
 
           cur_ntodo -= null_pos;
           if (cur_ntodo <= 0) {
@@ -650,7 +648,7 @@ int
 StufferCacheIncomingRequest(CacheVC * cache_vc)
 {
   /* extract url out of this vc.
-     use local buffer to avoid another xmalloc(), otherwise we could just
+     use local buffer to avoid another ats_malloc(), otherwise we could just
      use url_obj->string_get() */
 #define BUF_SIZE 512
   char url[BUF_SIZE];

Modified: trafficserver/traffic/trunk/proxy/congest/MT_hashtable.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/congest/MT_hashtable.h?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/congest/MT_hashtable.h (original)
+++ trafficserver/traffic/trunk/proxy/congest/MT_hashtable.h Wed Sep  7 17:28:10 2011
@@ -45,7 +45,7 @@ template<class key_t, class data_t> stru
 
   static HashTableEntry *alloc()
   {
-    return (HashTableEntry *) xmalloc(sizeof(HashTableEntry));
+    return (HashTableEntry *)ats_malloc(sizeof(HashTableEntry));
   }
   static void free(HashTableEntry * entry)
   {

Modified: trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc Wed Sep  7 17:28:10 2011
@@ -126,7 +126,7 @@ new_HdrHeap(int size)
     size = HDR_HEAP_DEFAULT_SIZE;
     h = (HdrHeap *) hdrHeapAllocator.alloc_void();
   } else {
-    h = (HdrHeap *) xmalloc(size);
+    h = (HdrHeap *)ats_malloc(size);
   }
 
 //    Debug("hdrs", "Allocated header heap in size %d", size);
@@ -157,7 +157,7 @@ new_HdrStrHeap(int requested_size)
     sh = (HdrStrHeap *) strHeapAllocator.alloc_void();
   } else {
     alloc_size = ROUND(alloc_size, HDR_STR_HEAP_DEFAULT_SIZE*2);
-    sh = (HdrStrHeap *) xmalloc(alloc_size);
+    sh = (HdrStrHeap *)ats_malloc(alloc_size);
   }
 
 //    Debug("hdrs", "Allocated string heap in size %d", alloc_size);

Modified: trafficserver/traffic/trunk/proxy/hdrs/HdrTest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/HdrTest.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/HdrTest.cc (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/HdrTest.cc Wed Sep  7 17:28:10 2011
@@ -160,7 +160,7 @@ HdrTest::test_error_page_selection()
   for (i = 0; i < nsets; i++) {
     HttpBodySetRawData *body_set;
 
-    body_set = (HttpBodySetRawData *) xmalloc(sizeof(HttpBodySetRawData));
+    body_set = (HttpBodySetRawData *)ats_malloc(sizeof(HttpBodySetRawData));
     body_set->magic = 0;
     body_set->set_name = (char *) (sets[i].set_name);
     body_set->content_language = (char *) (sets[i].content_language);
@@ -910,8 +910,8 @@ comp_http_hdr(HTTPHdr * h1, HTTPHdr * h2
     return "length mismatch";
   }
 
-  h1_pbuf = (char *) xmalloc(h1_len + 1);
-  h2_pbuf = (char *) xmalloc(h2_len + 1);
+  h1_pbuf = (char *)ats_malloc(h1_len + 1);
+  h2_pbuf = (char *)ats_malloc(h2_len + 1);
 
   p_index = p_dumpoffset = 0;
   rval = h1->print(h1_pbuf, h1_len, &p_index, &p_dumpoffset);

Modified: trafficserver/traffic/trunk/proxy/http/HttpMessageBody.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpMessageBody.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpMessageBody.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpMessageBody.cc Wed Sep  7 17:28:10 2011
@@ -72,7 +72,7 @@ HttpMessageBody::MakeErrorBodyVA(int64_t
       if (output_length > max_buffer_length)
         return (NULL);
       else
-        outbuf = (char *) xmalloc(output_length);
+        outbuf = (char *)ats_malloc(output_length);
     }
 
     l = 0;

Modified: trafficserver/traffic/trunk/proxy/http/remap/StringHash.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/StringHash.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/StringHash.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/StringHash.cc Wed Sep  7 17:28:10 2011
@@ -55,8 +55,8 @@ StringHash::StringHash(int _hash_size, b
     hash_mask_size++;
   }
 
-  if ((hash = (StringHashEntry **) xmalloc(hash_size * sizeof(StringHashEntry *))) != NULL)
-    memset(hash, 0, hash_size * sizeof(StringHashEntry *));
+  hash = (StringHashEntry **)ats_malloc(hash_size * sizeof(StringHashEntry *));
+  memset(hash, 0, hash_size * sizeof(StringHashEntry *));
   //printf("StringHash::StringHash  hash = 0x%0X, mask = 0x%0lX, hash_mask_size = %d\n",hash_size,(long)hash_mask,hash_mask_size);
 }
 
@@ -127,10 +127,9 @@ StringHash::find_or_add(void *_ptr, cons
 
   if (ignore_case) {
     if (unlikely(_strsize >= (int) sizeof(tbuf))) {
-      if ((tbufp = (tbuf_alloc = (char *) xmalloc(_strsize + 1))) == NULL) {
-        tbufp = &tbuf[0];
-        _strsize = (int) (sizeof(tbuf) - 1);
-      }
+      tbufp = (tbuf_alloc = (char *)ats_malloc(_strsize + 1));
+      tbufp = &tbuf[0];
+      _strsize = (int) (sizeof(tbuf) - 1);
     } else
       tbufp = &tbuf[0];
     for (htid = 0; htid < _strsize; htid++) {
@@ -195,10 +194,10 @@ StringHashEntry::setstr(const char *_str
   }
   if ((strsize = _strsize) < 0)
     strsize = strlen(_str);
-  if (likely((str = (char *) xmalloc(strsize + 1)) != NULL)) {
-    if (strsize)
-      memcpy(str, _str, strsize);
-    str[strsize] = 0;
-  }
+  str = (char *)ats_malloc(strsize + 1);
+  if (strsize)
+    memcpy(str, _str, strsize);
+  str[strsize] = 0;
+
   return str;
 }

Modified: trafficserver/traffic/trunk/proxy/logging/LogFilter.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogFilter.cc?rev=1166280&r1=1166279&r2=1166280&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogFilter.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogFilter.cc Wed Sep  7 17:28:10 2011
@@ -86,7 +86,7 @@ LogFilterString::_setValues(size_t n, ch
     for (size_t i = 0; i < n; ++i) {
       m_value[i] = xstrdup(value[i]);
       m_length[i] = strlen(value[i]);
-      m_value_uppercase[i] = (char *) xmalloc((unsigned int) m_length[i] + 1);
+      m_value_uppercase[i] = (char *)ats_malloc((unsigned int) m_length[i] + 1);
       size_t j;
       for (j = 0; j < m_length[i]; ++j) {
         m_value_uppercase[i][j] = ParseRules::ink_toupper(m_value[i][j]);
@@ -206,8 +206,7 @@ bool LogFilterString::toss_this_entry(Lo
   size_t marsh_len = m_field->marshal_len(lad);      // includes null termination
 
   if (marsh_len > BUFSIZE) {
-    big_buf = (char *) xmalloc((unsigned int) marsh_len);
-    ink_assert(big_buf != NULL);
+    big_buf = (char *)ats_malloc((unsigned int) marsh_len);
     buf = big_buf;
   }
 
@@ -236,7 +235,7 @@ bool LogFilterString::toss_this_entry(Lo
   case CASE_INSENSITIVE_CONTAIN:
     {
       if (big_buf) {
-        big_buf_upper = (char *) xmalloc((unsigned int) marsh_len);
+        big_buf_upper = (char *)ats_malloc((unsigned int) marsh_len);
         buf_upper = big_buf_upper;
       }
       for (size_t i = 0; i < marsh_len; i++) {



Mime
View raw message