Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 21 additions & 49 deletions activemq-cpp/src/main/decaf/lang/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,13 @@ void System::arraycopy(const char* src, std::size_t srcPos, char* dest,
__FILE__, __LINE__, "Given Source Pointer was null.");
}

if (src == NULL) {
if (dest == NULL) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null.");
__FILE__, __LINE__, "Given Destination 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);
}
::memmove(dest + destPos, src + srcPos, length);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -144,17 +140,13 @@ void System::arraycopy(const unsigned char* src, std::size_t srcPos,
__FILE__, __LINE__, "Given Source Pointer was null.");
}

if (src == NULL) {
if (dest == NULL) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null.");
__FILE__, __LINE__, "Given Destination 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);
}
::memmove(dest + destPos, src + srcPos, length);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -166,17 +158,13 @@ void System::arraycopy(const short* src, std::size_t srcPos,
__FILE__, __LINE__, "Given Source Pointer was null.");
}

if (src == NULL) {
if (dest == NULL) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null.");
__FILE__, __LINE__, "Given Destination Pointer was null.");
}

// Now we try and copy, could still segfault.
if (src != dest) {
::memcpy(dest + destPos, src + srcPos, length * sizeof(short));
} else {
::memmove(dest + destPos, src + srcPos, length * sizeof(short));
}
::memmove(dest + destPos, src + srcPos, length * sizeof(short));
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -188,17 +176,13 @@ void System::arraycopy(const int* src, std::size_t srcPos,
__FILE__, __LINE__, "Given Source Pointer was null.");
}

if (src == NULL) {
if (dest == NULL) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null.");
__FILE__, __LINE__, "Given Destination Pointer was null.");
}

// Now we try and copy, could still segfault.
if (src != dest) {
::memcpy(dest + destPos, src + srcPos, length * sizeof(int));
} else {
::memmove(dest + destPos, src + srcPos, length * sizeof(int));
}
::memmove(dest + destPos, src + srcPos, length * sizeof(int));
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -210,17 +194,13 @@ void System::arraycopy(const long long* src, std::size_t srcPos,
__FILE__, __LINE__, "Given Source Pointer was null.");
}

if (src == NULL) {
if (dest == NULL) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null.");
__FILE__, __LINE__, "Given Destination Pointer was null.");
}

// Now we try and copy, could still segfault.
if (src != dest) {
::memcpy(dest + destPos, src + srcPos, length * sizeof(long long));
} else {
::memmove(dest + destPos, src + srcPos, length * sizeof(long long));
}
::memmove(dest + destPos, src + srcPos, length * sizeof(long long));
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -232,17 +212,13 @@ void System::arraycopy(const float* src, std::size_t srcPos,
__FILE__, __LINE__, "Given Source Pointer was null.");
}

if (src == NULL) {
if (dest == NULL) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null.");
__FILE__, __LINE__, "Given Destination Pointer was null.");
}

// Now we try and copy, could still segfault.
if (src != dest) {
::memcpy(dest + destPos, src + srcPos, length * sizeof(float));
} else {
::memmove(dest + destPos, src + srcPos, length * sizeof(float));
}
::memmove(dest + destPos, src + srcPos, length * sizeof(float));
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -254,17 +230,13 @@ void System::arraycopy(const double* src, std::size_t srcPos,
__FILE__, __LINE__, "Given Source Pointer was null." );
}

if( src == NULL ) {
if( dest == NULL ) {
throw NullPointerException(
__FILE__, __LINE__, "Given Source Pointer was null." );
__FILE__, __LINE__, "Given Destination Pointer was null." );
}

// Now we try and copy, could still segfault.
if( src != dest ) {
::memcpy( dest + destPos, src + srcPos, length * sizeof( double ) );
} else {
::memmove( dest + destPos, src + srcPos, length * sizeof( double ) );
}
::memmove( dest + destPos, src + srcPos, length * sizeof( double ) );
}

////////////////////////////////////////////////////////////////////////////////
Expand Down