title: JNI method help. Memcpy with destination offset
body: <p>I am making a Jni replacement method for FloatBuffer.put(), since on Android 2.x and below, the FloatBuffer.put() method is inefficiently implemented as stated <a href="http://www.badlogicgames.com/wiki/index.php/Direct_Bulk_FloatBuffer.put_is_slow" rel="nofollow">here</a>. However, I want to be able to able to put a given array of src floats to a specified offset in the dst floatbuffer, as I could with position() and put(). With this in mind, I implemented this JNI method.</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_voidseer_voidengine_mesh_Vertices_PutFloatsJni
  (JNIEnv *env, jclass, jfloatArray src, jobject dst, jint numFloats, jint dstOffset )
  {
          float* pDst = (float*)env-&gt;GetDirectBufferAddress( dst );
          float* pSrc = (float*)env-&gt;GetPrimitiveArrayCritical(src, 0);
  
          memcpy( pDst + (dstOffset &lt;&lt; 2), pSrc, numFloats &lt;&lt; 2 );
  
          env-&gt;ReleasePrimitiveArrayCritical(src, pSrc, 0);
  }
  </code></pre>
  
  <p>However, something seems wrong. My game engine does not draw my entities like it should. Can someone spot something wrong I am doing here in this function?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <p>Just got it to work with this code.</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_voidseer_voidengine_mesh_Vertices_PutFloatsJni
  (JNIEnv *env, jclass, jfloatArray src, jobject dst, jint numFloats, jint dstOffset )
  {
          float* pDst = (float*)env-&gt;GetDirectBufferAddress( dst );
          float* pSrc = (float*)env-&gt;GetPrimitiveArrayCritical(src, 0);
  
          memcpy( &amp;pDst[dstOffset], pSrc, numFloats &lt;&lt; 2 );
  
          env-&gt;ReleasePrimitiveArrayCritical(src, pSrc, 0);
  }
  </code></pre>