trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1165142 - in /trafficserver/traffic/trunk: iocore/cache/ lib/ts/ mgmt/api/ proxy/ proxy/http/remap/ proxy/logging/
Date Mon, 05 Sep 2011 01:45:32 GMT
Author: zwoop
Date: Mon Sep  5 01:45:31 2011
New Revision: 1165142

URL: http://svn.apache.org/viewvc?rev=1165142&view=rev
Log:
TS-567 Clean up ink_malloc/free to ats_malloc/free, and remove unused code

Modified:
    trafficserver/traffic/trunk/iocore/cache/CacheDir.cc
    trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h
    trafficserver/traffic/trunk/lib/ts/IpMapConf.cc
    trafficserver/traffic/trunk/lib/ts/Regex.cc
    trafficserver/traffic/trunk/lib/ts/ink_hash_table.cc
    trafficserver/traffic/trunk/lib/ts/ink_memory.cc
    trafficserver/traffic/trunk/lib/ts/ink_memory.h
    trafficserver/traffic/trunk/lib/ts/ink_queue.cc
    trafficserver/traffic/trunk/lib/ts/ink_resource.cc
    trafficserver/traffic/trunk/lib/ts/ink_resource.h
    trafficserver/traffic/trunk/lib/ts/ink_string.cc
    trafficserver/traffic/trunk/lib/ts/ink_string.h
    trafficserver/traffic/trunk/mgmt/api/CoreAPIShared.cc
    trafficserver/traffic/trunk/proxy/TestHook.cc
    trafficserver/traffic/trunk/proxy/http/remap/Trie.h
    trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc
    trafficserver/traffic/trunk/proxy/logging/LogAccess.cc

Modified: trafficserver/traffic/trunk/iocore/cache/CacheDir.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/CacheDir.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/CacheDir.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/CacheDir.cc Mon Sep  5 01:45:31 2011
@@ -940,8 +940,8 @@ sync_cache_dir_on_shutdown(void)
 
     if (buflen < dirlen) {
       if (buf)
-        ink_memalign_free(buf);
-      buf = (char *) ink_memalign(sysconf(_SC_PAGESIZE), dirlen);       // buf = (char*)
valloc (dirlen);
+        ats_memalign_free(buf);
+      buf = (char *)ats_memalign(sysconf(_SC_PAGESIZE), dirlen);       // buf = (char*) valloc
(dirlen);
       buflen = dirlen;
     }
 
@@ -961,7 +961,7 @@ sync_cache_dir_on_shutdown(void)
   }
   Debug("cache_dir_sync", "sync done");
   if (buf)
-    ink_memalign_free(buf);
+    ats_memalign_free(buf);
 }
 
 
@@ -981,7 +981,7 @@ Lrestart:
   if (vol >= gnvol) {
     vol = 0;
     if (buf) {
-      ink_memalign_free(buf);
+      ats_memalign_free(buf);
       buf = 0;
       buflen = 0;
     }
@@ -1044,8 +1044,8 @@ Lrestart:
       d->header->dirty = 0;
       if (buflen < dirlen) {
         if (buf)
-          ink_memalign_free(buf);
-        buf = (char *) ink_memalign(sysconf(_SC_PAGESIZE), dirlen);
+          ats_memalign_free(buf);
+        buf = (char *)ats_memalign(sysconf(_SC_PAGESIZE), dirlen);
         buflen = dirlen;
       }
       d->header->sync_serial++;

Modified: trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h (original)
+++ trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h Mon Sep  5 01:45:31 2011
@@ -256,16 +256,16 @@ struct Vol: public Continuation
       dir_sync_waiting(0), dir_sync_in_progress(0), writing_end_marker(0) {
     open_dir.mutex = mutex;
 #if defined(_WIN32)
-    agg_buffer = (char *) malloc(AGG_SIZE);
+    agg_buffer = (char *)ats_malloc(AGG_SIZE);
 #else
-    agg_buffer = (char *) ink_memalign(sysconf(_SC_PAGESIZE), AGG_SIZE);
+    agg_buffer = (char *)ats_memalign(sysconf(_SC_PAGESIZE), AGG_SIZE);
 #endif
     memset(agg_buffer, 0, AGG_SIZE);
     SET_HANDLER(&Vol::aggWrite);
   }
 
   ~Vol() {
-    ink_memalign_free(agg_buffer);
+    ats_memalign_free(agg_buffer);
   }
 };
 

Modified: trafficserver/traffic/trunk/lib/ts/IpMapConf.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/IpMapConf.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/IpMapConf.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/IpMapConf.cc Mon Sep  5 01:45:31 2011
@@ -73,7 +73,7 @@ Load_IpMap_From_File(IpMap* map, int fd,
   FILE* f = fdopen(dup(fd), "r"); // dup so we don't close the original fd.
   if (f) zret = Load_IpMap_From_File(map, f, key_str);
   else {
-    zret = (char *) ink_malloc(ERR_STRING_LEN);
+    zret = (char *)ats_malloc(ERR_STRING_LEN);
     snprintf(zret, ERR_STRING_LEN, "Unable to reopen file descriptor as stream %d:%s", errno,
strerror(errno));
   }
   return zret;
@@ -117,7 +117,7 @@ Load_IpMap_From_File(IpMap* map, FILE* f
       if (!skip_space(line, n, i)) break;
 
       if (0 != read_addr(line, n,  &i, ink_inet_sa_cast(&laddr), err_buff)) {
-        char *error_str = (char *) ink_malloc(ERR_STRING_LEN);
+        char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
         snprintf(error_str, ERR_STRING_LEN, "Invalid input configuration (%s) at line %d
offset %d - '%s'", err_buff, line_no, i, line);
         return error_str;
       }
@@ -134,24 +134,24 @@ Load_IpMap_From_File(IpMap* map, FILE* f
         // Now, read the end of the IP range
         ++i;
         if (!skip_space(line, n, i)) {
-          char *error_str = (char *) ink_malloc(ERR_STRING_LEN);
+          char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
           snprintf(error_str, ERR_STRING_LEN, "Invalid input (unterminated range) at line
%d offset %d - '%s'", line_no, i, line);
           return error_str;
         } else if (0 != read_addr(line, n, &i, ink_inet_sa_cast(&raddr), err_buff))
{
-          char *error_str = (char *) ink_malloc(ERR_STRING_LEN);
+          char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
           snprintf(error_str, ERR_STRING_LEN, "Invalid input (%s) at line %d offset %d -
'%s'", err_buff, line_no, i, line);
           return error_str;
         }
         map->mark(ink_inet_sa_cast(&laddr), ink_inet_sa_cast(&raddr));
         if (!skip_space(line, n, i)) break;
         if (line[i] != ',') {
-          char *error_str = (char *) ink_malloc(ERR_STRING_LEN);
+          char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
           snprintf(error_str, ERR_STRING_LEN, "Invalid input (expecting comma) at line %d
offset %d - '%s'", line_no, i, line);
           return error_str;
         }
         ++i;
       } else {
-        char *error_str = (char *) ink_malloc(ERR_STRING_LEN);
+        char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
         snprintf(error_str, ERR_STRING_LEN, "Invalid input (expecting dash or comma) at line
%d offset %d", line_no, i);
         return error_str;
       }

Modified: trafficserver/traffic/trunk/lib/ts/Regex.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/Regex.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/Regex.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/Regex.cc Mon Sep  5 01:45:31 2011
@@ -35,9 +35,9 @@ DFA::~DFA()
     if (p->_re)
       pcre_free(p->_re);
     if(p->_p)
-      ink_free(p->_p);
+      ats_free(p->_p);
     t = p->_next;
-    ink_free(p);
+    ats_free(p);
     p = t;
   } 
 }
@@ -49,7 +49,7 @@ DFA::build(const char *pattern, REFlags 
   int erroffset;
   dfa_pattern* ret;
   
-  ret = (dfa_pattern*) ink_malloc(sizeof(dfa_pattern));
+  ret = (dfa_pattern*)ats_malloc(sizeof(dfa_pattern));
   ret->_p = NULL;
   
   if (flags & RE_CASE_INSENSITIVE)
@@ -58,14 +58,14 @@ DFA::build(const char *pattern, REFlags 
     ret->_re = pcre_compile(pattern, PCRE_ANCHORED, &error, &erroffset, NULL);
   
   if (error) {
-    ink_free(ret);
+    ats_free(ret);
     return NULL;
   }
   
   ret->_pe = pcre_study(ret->_re, 0, &error);
   
   if (error) {
-    ink_free(ret);
+    ats_free(ret);
     return NULL;
   }
   

Modified: trafficserver/traffic/trunk/lib/ts/ink_hash_table.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_hash_table.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_hash_table.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_hash_table.cc Mon Sep  5 01:45:31 2011
@@ -60,7 +60,7 @@ ink_hash_table_create(InkHashTableKeyTyp
   Tcl_HashTable *tcl_ht_ptr;
   int tcl_key_type;
 
-  tcl_ht_ptr = ink_type_malloc(Tcl_HashTable);
+  tcl_ht_ptr = (Tcl_HashTable*)ats_malloc(sizeof(Tcl_HashTable));
 
   tcl_key_type = -1;
   if (key_type == InkHashTableKeyType_String)
@@ -92,7 +92,7 @@ ink_hash_table_destroy(InkHashTable * ht
 
   tcl_ht_ptr = (Tcl_HashTable *) ht_ptr;
   Tcl_DeleteHashTable(tcl_ht_ptr);
-  ink_free(tcl_ht_ptr);
+  ats_free(tcl_ht_ptr);
   return (InkHashTable *) 0;
 }                               /* End ink_hash_table_destroy */
 
@@ -114,7 +114,7 @@ _ink_hash_table_free_entry_value(InkHash
 
   value = ink_hash_table_entry_value(ht_ptr, e);
   if (value != NULL) {
-    ink_free(value);
+    ats_free(value);
   }
 
   return (0);
@@ -454,8 +454,8 @@ ink_hash_table_replace_string(InkHashTab
   if (new_value == 0) {
     old_str = (char *) ink_hash_table_entry_value(ht_ptr, he_ptr);
     if (old_str)
-      ink_free(old_str);
+      ats_free(old_str);
   }
 
-  ink_hash_table_set_entry(ht_ptr, he_ptr, (InkHashTableValue) (ink_duplicate_string(string_value)));
+  ink_hash_table_set_entry(ht_ptr, he_ptr, (InkHashTableValue)(xstrdup(string_value)));
 }                               /* End ink_hash_table_replace_string */

Modified: trafficserver/traffic/trunk/lib/ts/ink_memory.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_memory.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_memory.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_memory.cc Mon Sep  5 01:45:31 2011
@@ -47,7 +47,7 @@
 
 
 void *
-ink_malloc(size_t size)
+ats_malloc(size_t size)
 {
   void *ptr = NULL;
 
@@ -63,48 +63,48 @@ ink_malloc(size_t size)
   if (likely(size > 0)) {
     if (unlikely((ptr = malloc(size)) == NULL)) {
       xdump();
-      ink_fatal(1, "ink_malloc: couldn't allocate %d bytes", size);
+      ink_fatal(1, "ats_malloc: couldn't allocate %d bytes", size);
     }
   }
-  return (ptr);
-}                               /* End ink_malloc */
+  return ptr;
+}                               /* End ats_malloc */
 
 
 void *
-ink_calloc(size_t nelem, size_t elsize)
+ats_calloc(size_t nelem, size_t elsize)
 {
   void *ptr = calloc(nelem, elsize);
   if (unlikely(ptr == NULL)) {
     xdump();
-    ink_fatal(1, "ink_calloc: couldn't allocate %d %d byte elements", nelem, elsize);
+    ink_fatal(1, "ats_calloc: couldn't allocate %d %d byte elements", nelem, elsize);
   }
-  return (ptr);
-}                               /* End ink_calloc */
+  return ptr;
+}                               /* End ats_calloc */
 
 
 void *
-ink_realloc(void *ptr, size_t size)
+ats_realloc(void *ptr, size_t size)
 {
   void *newptr = realloc(ptr, size);
   if (unlikely(newptr == NULL)) {
     xdump();
-    ink_fatal(1, "ink_realloc: couldn't reallocate %d bytes", size);
+    ink_fatal(1, "ats_realloc: couldn't reallocate %d bytes", size);
   }
-  return (newptr);
-}                               /* End ink_realloc */
+  return newptr;
+}                               /* End ats_realloc */
 
 
 void
-ink_memalign_free(void *ptr)
+ats_memalign_free(void *ptr)
 {
   if (likely(ptr)) {
-    ink_free(ptr);
+    ats_free(ptr);
   }
 }
 
 
 void *
-ink_memalign(size_t alignment, size_t size)
+ats_memalign(size_t alignment, size_t size)
 {
 #ifndef NO_MEMALIGN
 
@@ -112,28 +112,28 @@ ink_memalign(size_t alignment, size_t si
 
 #if TS_HAS_POSIX_MEMALIGN
   if (alignment <= 8)
-    return ink_malloc(size);
+    return ats_malloc(size);
 
   int retcode = posix_memalign(&ptr, alignment, size);
   if (unlikely(retcode)) {
     if (retcode == EINVAL) {
-      ink_fatal(1, "ink_memalign: couldn't allocate %d bytes at alignment %d - invalid alignment
parameter",
+      ink_fatal(1, "ats_memalign: couldn't allocate %d bytes at alignment %d - invalid alignment
parameter",
                 (int) size, (int) alignment);
     } else if (retcode == ENOMEM) {
-      ink_fatal(1, "ink_memalign: couldn't allocate %d bytes at alignment %d - insufficient
memory",
+      ink_fatal(1, "ats_memalign: couldn't allocate %d bytes at alignment %d - insufficient
memory",
                 (int) size, (int) alignment);
     } else {
-      ink_fatal(1, "ink_memalign: couldn't allocate %d bytes at alignment %d - unknown error
%d",
+      ink_fatal(1, "ats_memalign: couldn't allocate %d bytes at alignment %d - unknown error
%d",
                 (int) size, (int) alignment, retcode);
     }
   }
 #else
   ptr = memalign(alignment, size);
   if (unlikely(ptr == NULL)) {
-    ink_fatal(1, "ink_memalign: couldn't allocate %d bytes at alignment %d", (int) size,
(int) alignment);
+    ink_fatal(1, "ats_memalign: couldn't allocate %d bytes at alignment %d", (int) size,
(int) alignment);
   }
 #endif
-  return (ptr);
+  return ptr;
 #else
 #if defined(freebsd) || defined(darwin)
   /*
@@ -166,29 +166,20 @@ ink_memalign(size_t alignment, size_t si
 # endif
 #endif /* #ifndef NO_MEMALIGN */
   return NULL;
-}                               /* End ink_memalign */
+}                               /* End ats_memalign */
 
 void
-ink_free(void *ptr)
+ats_free(void *ptr)
 {
   if (likely(ptr != NULL))
     free(ptr);
   else
-    ink_warning("ink_free: freeing a NULL pointer");
-}                               /* End ink_free */
+    ink_warning("ats_free: freeing a NULL pointer");
+}                               /* End ats_free */
 
 
-/* this routine has been renamed --- this stub is for portability & will disappear */
-
-char *
-ink_duplicate_string(char *ptr)
-{
-  ink_assert(!"don't use this slow code!");
-  return (ink_string_duplicate(ptr));
-}                               /* End ink_duplicate_string */
-
 void *
-ink_memcpy(void *s1, const void *s2, int n)
+ats_memcpy(void *s1, const void *s2, int n)
 {
   register int i;
   register char *s, *d;
@@ -272,12 +263,5 @@ ink_memcpy(void *s1, const void *s2, int
     memcpy(s1, s2, n);
   }
 
-  return (s1);
-}                               /* End ink_memcpy */
-
-void
-ink_bcopy(void *s1, void *s2, size_t n)
-{
-  ink_assert(!"don't use this slow code!");
-  ink_memcpy(s2, s1, n);
-}                               /* End ink_bcopy */
+  return s1;
+}                               /* End ats_memcpy */

Modified: trafficserver/traffic/trunk/lib/ts/ink_memory.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_memory.h?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_memory.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_memory.h Mon Sep  5 01:45:31 2011
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  Memory allocation routines for libts.
 
   @section license License
 
@@ -20,15 +20,6 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  */
-
-/****************************************************************************
-
-  ink_memory.h
-
-  Memory allocation routines for libts
-
- ****************************************************************************/
-
 #ifndef _ink_memory_h_
 #define	_ink_memory_h_
 
@@ -39,26 +30,13 @@
 extern "C"
 {
 #endif                          /* __cplusplus */
-
-  typedef struct
-  {
-    void *ptr;
-    unsigned int length;
-  } InkMemoryBlock;
-
-#define ink_type_malloc(type)       (type *)ink_malloc(sizeof(type));
-#define ink_type_malloc_n(n,type)   (type *)ink_malloc((n) * sizeof(type));
-#define ink_type_calloc(n,type)     (type *)ink_calloc((n),sizeof(type));
-
-  void *ink_malloc(size_t size);
-  void *ink_calloc(size_t nelem, size_t elsize);
-  void *ink_realloc(void *ptr, size_t size);
-  void *ink_memalign(size_t alignment, size_t size);
-  void ink_free(void *ptr);
-  void ink_memalign_free(void *ptr);
-  char *ink_duplicate_string(char *ptr);        /* obsoleted by ink_string_duplicate ---
don't use */
-  void *ink_memcpy(void *s1, const void *s2, int n);
-  void ink_bcopy(void *s1, void *s2, size_t n);
+  void *ats_malloc(size_t size);
+  void *ats_calloc(size_t nelem, size_t elsize);
+  void *ats_realloc(void *ptr, size_t size);
+  void *ats_memalign(size_t alignment, size_t size);
+  void ats_free(void *ptr);
+  void ats_memalign_free(void *ptr);
+  void *ats_memcpy(void *s1, const void *s2, int n);
 
 #ifdef __cplusplus
 }

Modified: trafficserver/traffic/trunk/lib/ts/ink_queue.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_queue.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_queue.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_queue.cc Mon Sep  5 01:45:31 2011
@@ -111,7 +111,7 @@ ink_freelist_init(InkFreeList * f,
 
   /* its safe to add to this global list because ink_freelist_init()
      is only called from single-threaded initialization code. */
-  if ((fll = (ink_freelist_list *) ink_malloc(sizeof(ink_freelist_list))) != 0) {
+  if ((fll = (ink_freelist_list *)ats_malloc(sizeof(ink_freelist_list))) != 0) {
     fll->fl = f;
     fll->next = freelists;
     freelists = fll;
@@ -147,7 +147,8 @@ ink_freelist_init(InkFreeList * f,
 InkFreeList *
 ink_freelist_create(const char *name, uint32_t type_size, uint32_t chunk_size, uint32_t offset,
uint32_t alignment)
 {
-  InkFreeList *f = ink_type_malloc(InkFreeList);
+  InkFreeList *f = (InkFreeList *)ats_malloc(sizeof(InkFreeList));
+
   ink_freelist_init(f, name, type_size, chunk_size, offset, alignment);
   return f;
 }
@@ -213,9 +214,9 @@ ink_freelist_new(InkFreeList * f)
     ink_mutex_release(&(f->freelist_mutex));
 
     if (alignment) {
-      foo = ink_memalign(alignment, type_size);
+      foo = ats_memalign(alignment, type_size);
     } else {
-      foo = ink_malloc(type_size);
+      foo = ats_malloc(type_size);
     }
     if (likely(foo))
       fl_memadd(type_size);
@@ -258,9 +259,9 @@ ink_freelist_new(InkFreeList * f)
       char *oldsbrk = (char *) sbrk(0), *newsbrk = NULL;
 #endif
       if (f->alignment)
-        newp = ink_memalign(f->alignment, f->chunk_size * type_size);
+        newp = ats_memalign(f->alignment, f->chunk_size * type_size);
       else
-        newp = ink_malloc(f->chunk_size * type_size);
+        newp = ats_malloc(f->chunk_size * type_size);
       if (newp)
         fl_memadd(f->chunk_size * type_size);
 #ifdef DEBUG
@@ -280,7 +281,7 @@ ink_freelist_new(InkFreeList * f)
         add = 0;
         mask = ~0;
       }
-      newp = ink_malloc(f->chunk_size * type_size + add);
+      newp = ats_malloc(f->chunk_size * type_size + add);
       if (newp)
         fl_memadd(f->chunk_size * type_size + add);
       newp = (void *) ((((uintptr_t) newp) + add) & mask);

Modified: trafficserver/traffic/trunk/lib/ts/ink_resource.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_resource.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_resource.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_resource.cc Mon Sep  5 01:45:31 2011
@@ -707,14 +707,14 @@ void
 _xfree(void *mem)
 {
   if (likely(mem))
-    ink_free(mem);
+    ats_free(mem);
 }
 
 void *
 _xfree_null(void *mem)
 {
   if (likely(mem))
-    ink_free(mem);
+    ats_free(mem);
   return NULL;
 }
 
@@ -723,14 +723,14 @@ void *
 _xmalloc(unsigned int size, const char *path)
 {
   NOWARN_UNUSED(path);
-  return ink_malloc(size);
+  return ats_malloc(size);
 }
 
 void *
 _xrealloc(void *ptr, unsigned int size, const char *path)
 {
   NOWARN_UNUSED(path);
-  return ink_realloc(ptr, size);
+  return ats_realloc(ptr, size);
 }
 
 char *
@@ -743,7 +743,7 @@ _xstrdup(const char *str, int length, co
     if (length < 0) {
       length = strlen(str);
     }
-    newstr = (char *) ink_malloc(length + 1);
+    newstr = (char *)ats_malloc(length + 1);
     if (likely(newstr != NULL)) {
       strncpy(newstr, str, length);
       newstr[length] = '\0';

Modified: trafficserver/traffic/trunk/lib/ts/ink_resource.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_resource.h?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_resource.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_resource.h Mon Sep  5 01:45:31 2011
@@ -86,23 +86,20 @@ static inline void
 xfree(void *mem)
 {
   if (mem)
-    ink_free(mem);
+    ats_free(mem);
 }
 static inline void *
 xfree_null(void *mem)
 {
   if (mem)
-    ink_free(mem);
+    ats_free(mem);
   return NULL;
 }
 
-//#else
-//#define xfree(_mem)  if(_mem){ink_free((_mem));}
-//#define xfree_null(_mem)  if(_mem){ink_free((_mem));_mem = NULL;}
 #endif
 
-#define xmalloc(s)        ink_malloc ((s))
-#define xrealloc(p,s)     ink_realloc ((p),(s))
+#define xmalloc(s)        ats_malloc ((s))
+#define xrealloc(p,s)     ats_realloc ((p),(s))
 #define xstrdup(p)        _xstrdup ((p), -1, NULL)
 #define xstrndup(p,n)     _xstrdup ((p), n, NULL)
 #define xtrack(p)         p

Modified: trafficserver/traffic/trunk/lib/ts/ink_string.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_string.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_string.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_string.cc Mon Sep  5 01:45:31 2011
@@ -189,29 +189,6 @@ ink_string_append(char *dest, char *src,
 
 /*---------------------------------------------------------------------------*
 
-  char *ink_string_duplicate(char *ptr)
-
-  This routine allocates memory for the string <ptr>, and copies the string
-  into the new buffer.  The pointer to the new buffer is returned.
-
- *---------------------------------------------------------------------------*/
-
-char *
-ink_string_duplicate(char *ptr)
-{
-  char *n = NULL;
-
-  if (likely(ptr)) {
-    const size_t nSize = strlen(ptr) + 1;
-    n = (char *) ink_malloc(nSize);
-    ink_strncpy(n, ptr, nSize);
-  }
-  return (n);
-}                               /* End ink_string_duplicate */
-
-
-/*---------------------------------------------------------------------------*
-
   char *ink_string_find_dotted_extension(char *str, char *ext, int max_ext_len)
 
   This routine takes a string <str>, copies the period-separated extension to

Modified: trafficserver/traffic/trunk/lib/ts/ink_string.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_string.h?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_string.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_string.h Mon Sep  5 01:45:31 2011
@@ -53,7 +53,6 @@ inkcoreapi char *ink_strncpy(char *dest,
 inkcoreapi char *ink_string_concatenate_strings(char *dest, ...);
 inkcoreapi char *ink_string_concatenate_strings_n(char *dest, int n, ...);
 inkcoreapi char *ink_string_append(char *dest, char *src, int n);
-inkcoreapi char *ink_string_duplicate(char *ptr);
 inkcoreapi char *ink_string_find_dotted_extension(char *str, char *ext, int max_ext_len);
 
 /* these are supposed to make your life easier */

Modified: trafficserver/traffic/trunk/mgmt/api/CoreAPIShared.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/api/CoreAPIShared.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/api/CoreAPIShared.cc (original)
+++ trafficserver/traffic/trunk/mgmt/api/CoreAPIShared.cc Mon Sep  5 01:45:31 2011
@@ -1,6 +1,7 @@
 /** @file
 
-  A brief file description
+  This file contains functions that are shared by local and remote
+  API; in particular it has helper functions used by TSMgmtAPI.cc
 
   @section license License
 
@@ -20,17 +21,6 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  */
-
-/*****************************************************************************
- * Filename: CoreAPIShared.cc
- * Purpose: This file contains functions that are shared by local and remote
- *          API; in particular it has helper functions used by TSMgmtAPI.cc
- * Created: 01/20/00
- * Created by: Lan Tran
- *
- *
- ***************************************************************************/
-
 #include "libts.h"
 
 #include "CoreAPIShared.h"
@@ -266,13 +256,13 @@ connectDirect(const char *host, int port
   // Connect to the specified port on the machine we're running on.
   name.sin_family = AF_INET;
   name.sin_port = htons(port);
-  //name.sin_addr.s_addr = inet_addr ("127.0.0.1");
+
   struct hostent *pHostent;
   pHostent = gethostbyname(host);
   if (!pHostent) {
     goto error;
   }
-  bcopy(pHostent->h_addr, (caddr_t) & (name.sin_addr), pHostent->h_length);
+  ats_memcpy((caddr_t)&(name.sin_addr), pHostent->h_addr, pHostent->h_length);
 
   do {
     err = connect(sock, (struct sockaddr *) &name, sizeof(name));

Modified: trafficserver/traffic/trunk/proxy/TestHook.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/TestHook.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/TestHook.cc (original)
+++ trafficserver/traffic/trunk/proxy/TestHook.cc Mon Sep  5 01:45:31 2011
@@ -348,7 +348,7 @@ StateMachine::fill()
   // write header
   if (hdr_bytes_left) {
     copy_size = min(n, hdr_bytes_left);
-    bcopy(scratch_space + header_size_written, ptr, copy_size);
+    ats_memcpy(ptr, scratch_space + header_size_written, copy_size);
     ptr += copy_size;
     header_size_written += copy_size;
     hdr_bytes_left -= copy_size;

Modified: trafficserver/traffic/trunk/proxy/http/remap/Trie.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/Trie.h?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/Trie.h (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/Trie.h Mon Sep  5 01:45:31 2011
@@ -122,7 +122,7 @@ Trie<T>::Insert(const char *key, T* valu
     if (!next_node) {
       while (i < key_len) {
         Debug("Trie::Insert", "Creating child node for char %c (%d)", key[i], key[i]);
-        curr_node->SetChild(key[i], static_cast<Node*>(ink_malloc(sizeof(Node))));
+        curr_node->SetChild(key[i], static_cast<Node*>(ats_malloc(sizeof(Node))));
         curr_node = curr_node->GetChild(key[i]);
         curr_node->Clear();
         ++i;
@@ -197,7 +197,7 @@ Trie<T>::_Clear(Node *node)
     child = node->GetChild(i);
     if (child) {
       _Clear(child);
-      ink_free(child);
+      ats_free(child);
     }
   }
 }

Modified: trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc Mon Sep  5 01:45:31 2011
@@ -532,8 +532,8 @@ UrlRewrite::UrlRewrite(const char *file_
     Warning("something failed during BuildTable() -- check your remap plugins!");
   }
 
-  pcre_malloc = &ink_malloc;
-  pcre_free = &ink_free;
+  pcre_malloc = &ats_malloc;
+  pcre_free = &ats_free;
 
   if (is_debug_tag_set("url_rewrite"))
     Print();
@@ -1978,7 +1978,7 @@ UrlRewrite::_destroyList(RegexMappingLis
       pcre_free(list_iter->re_extra);
     }
     if (list_iter->to_url_host_template) {
-      ink_free(list_iter->to_url_host_template);
+      ats_free(list_iter->to_url_host_template);
     }
     delete list_iter;
   }
@@ -2058,7 +2058,7 @@ UrlRewrite::_processRegexMappingConfig(c
   // in this buffer
   str = new_mapping->toUrl.host_get(&str_index); // reusing str and str_index
   reg_map->to_url_host_template_len = str_index;
-  reg_map->to_url_host_template = static_cast<char *>(ink_malloc(str_index));
+  reg_map->to_url_host_template = static_cast<char *>(ats_malloc(str_index));
   memcpy(reg_map->to_url_host_template, str, str_index);
 
   return true;
@@ -2073,7 +2073,7 @@ UrlRewrite::_processRegexMappingConfig(c
     reg_map->re_extra = NULL;
   }
   if (reg_map->to_url_host_template) {
-    ink_free(reg_map->to_url_host_template);
+    ats_free(reg_map->to_url_host_template);
     reg_map->to_url_host_template = NULL;
     reg_map->to_url_host_template_len = 0;
   }

Modified: trafficserver/traffic/trunk/proxy/logging/LogAccess.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccess.cc?rev=1165142&r1=1165141&r2=1165142&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccess.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccess.cc Mon Sep  5 01:45:31 2011
@@ -697,7 +697,7 @@ LogAccess::marshal_record(char *record, 
           num_chars =::strlen(out_buf) + 1;
           if (num_chars > max_chars) {
             // truncate string and write ellipsis at the end
-            ink_memcpy(ascii_buf, out_buf, max_chars - 4);
+            ats_memcpy(ascii_buf, out_buf, max_chars - 4);
             ascii_buf[max_chars - 1] = 0;
             ascii_buf[max_chars - 2] = '.';
             ascii_buf[max_chars - 3] = '.';
@@ -723,7 +723,7 @@ LogAccess::marshal_record(char *record, 
   }
 
   ink_debug_assert(num_chars <= max_chars);
-  ink_memcpy(buf, out_buf, num_chars);
+  ats_memcpy(buf, out_buf, num_chars);
 
 #ifdef PURIFY
   for (unsigned int i = num_chars + 1; i < max_chars; ++i) {



Mime
View raw message