activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r912047 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang: System.cpp System.h
Date Sat, 20 Feb 2010 00:13:45 GMT
Author: tabish
Date: Sat Feb 20 00:13:44 2010
New Revision: 912047

URL: http://svn.apache.org/viewvc?rev=912047&view=rev
Log:
Add a version of arraycopy for byte arrays

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp?rev=912047&r1=912046&r2=912047&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.cpp Sat Feb 20 00:13:44
2010
@@ -44,6 +44,12 @@
 #ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
 #endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
 
 #include <cstdlib>
 
@@ -66,6 +72,29 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void System::arraycopy( unsigned char* src, std::size_t srcPos,
+                        unsigned char* dest, std::size_t destPos, std::size_t length )
+    throw( decaf::lang::exceptions::NullPointerException ){
+
+    if( src == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "Given Source Pointer was null." );
+    }
+
+    if( src == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "Given Source Pointer was null." );
+    }
+
+    // Now we try and copy, could still segfault.
+    if( src != dest ) {
+        ::memcpy( dest + destPos, src + srcPos, length );
+    } else {
+        ::memmove( dest + destPos, src + srcPos, length );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void System::unsetenv( const std::string& name ) throw ( lang::Exception ) {
 
     apr_status_t result = APR_SUCCESS;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h?rev=912047&r1=912046&r2=912047&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/System.h Sat Feb 20 00:13:44
2010
@@ -21,6 +21,7 @@
 #include <decaf/util/Config.h>
 #include <decaf/util/Map.h>
 #include <decaf/lang/Exception.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/internal/AprPool.h>
 #include <string>
 
@@ -39,6 +40,15 @@
     public:  // Static Methods
 
         /**
+         * Copies the number of elements specified by length from the source array starting
at
+         * the given source offset specified by srcPos to the dest array starting at the
given
+         * destination offset given by destPos.
+         */
+        static void arraycopy( unsigned char* src, std::size_t srcPos,
+                               unsigned char* dest, std::size_t destPos, std::size_t length
)
+            throw( decaf::lang::exceptions::NullPointerException );
+
+        /**
          * Enumerates the system environment and returns a map of env variable
          * names to the string values they hold.
          * @return A Map of all environment variables.



Mime
View raw message