Skip to content

slight fixes for "templatized" arraycopy static methods. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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