axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r331933 - in /webservices/axis2/trunk/c/modules/util/src: axis2_string.h string.c
Date Wed, 09 Nov 2005 03:16:25 GMT
Author: samisa
Date: Tue Nov  8 19:16:16 2005
New Revision: 331933

URL: http://svn.apache.org/viewcvs?rev=331933&view=rev
Log:
Removed use of stringdup and implemented strdup with our own logic

Modified:
    webservices/axis2/trunk/c/modules/util/src/axis2_string.h
    webservices/axis2/trunk/c/modules/util/src/string.c

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_string.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_string.h?rev=331933&r1=331932&r2=331933&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_string.h (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_string.h Tue Nov  8 19:16:16 2005
@@ -19,7 +19,7 @@
 
 #include <axis2_defines.h>
 #include <axis2_error.h>
-#include <axis2_allocator.h>
+#include <axis2_env.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -32,11 +32,14 @@
  * @{
  */
 
-void* 
-axis2_strdup (const void *ptr);
+    void* 
+    axis2_strdup (const void *ptr, axis2_env_t **env);
 
-int 
-axis2_strcmp (const axis2_char_t * s1, const axis2_char_t * s2);
+    int 
+    axis2_strcmp (const axis2_char_t * s1, const axis2_char_t * s2);
+
+#define AXIS2_STRDUP(pts, env) axis2_strdup(pts, env)
+#define AXIS2_STRCMP(s1, s2) axis2_strcmp(s1, s2)
 
 /** @} */
     

Modified: webservices/axis2/trunk/c/modules/util/src/string.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/string.c?rev=331933&r1=331932&r2=331933&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/string.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/string.c Tue Nov  8 19:16:16 2005
@@ -17,13 +17,23 @@
 #include <axis2_string.h>
 #include <stdlib.h>
 #include <string.h>
+#include <axis2.h>
 
-void* 
-axis2_strdup (const void *ptr)
+void* AXIS2_CALL
+axis2_strdup (const void *ptr, axis2_env_t **env)
 {
+    AXIS2_FUNC_PARAM_CHECK(ptr, env, NULL);
     if (ptr)
     {
-        return (void *) strdup (ptr);
+        int len = strlen(ptr);
+        char* str = (char*) AXIS2_MALLOC( (*env)->allocator, sizeof(char) * (len + 1 ));
+        if (!str)
+        {
+            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+            return NULL;
+        }
+        memcpy(str, ptr, len + 1);
+        return (void *) str;
     }
     else
     {
@@ -31,7 +41,7 @@
     }
 }
 
-int 
+int AXIS2_CALL
 axis2_strcmp (const axis2_char_t * s1, const axis2_char_t * s2)
 {
     if (s1 && s2)



Mime
View raw message