You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2007/04/25 17:13:42 UTC

svn commit: r532383 - /harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c

Author: apetrenko
Date: Wed Apr 25 08:13:41 2007
New Revision: 532383

URL: http://svn.apache.org/viewvc?view=rev&rev=532383
Log:
Patch for HARMONY-3677 "[classlib][awt] Results of running checker tool"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c?view=diff&rev=532383&r1=532382&r2=532383
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c Wed Apr 25 08:13:41 2007
@@ -172,6 +172,8 @@
     memmove(decoder->input, decoder->inputPtr, decoder->bytesInBuffer);
   }
 
+  (*env)->ReleasePrimitiveArrayCritical(env, jInput, decoder->input, 0);
+
   (*env)->SetIntField(
       env, 
       obj, 
@@ -179,8 +181,6 @@
       bytesInBuffer - decoder->bytesInBuffer
     );
 
-  (*env)->ReleasePrimitiveArrayCritical(env, jInput, decoder->input, 0);
-
   if(decoder->stateVars.imageDataStarted) {
     if(!decoder->interlace) {
       scanlinesDecoded = decoder->pixelsDecoded / decoder->currentWidth -
@@ -242,19 +242,17 @@
  */
 JNIEXPORT jintArray JNICALL Java_org_apache_harmony_awt_gl_image_GifDecoder_toRGB
 (JNIEnv *env, jclass cls, jbyteArray jSrc, jbyteArray jColormap, jint transparentColor) {
-  unsigned int *intARGBColormap;
-  unsigned char *src = (*env)->GetPrimitiveArrayCritical(env, jSrc, 0);
-  unsigned char *colormap = (*env)->GetPrimitiveArrayCritical(env, jColormap, 0);
-
   unsigned int numPixels = (*env)->GetArrayLength(env, jSrc);
   unsigned int cmapSize = (*env)->GetArrayLength(env, jColormap);
+  // Create INT_ARGB colormap
+  unsigned int *intARGBColormap = malloc(cmapSize*sizeof(int));
   jintArray jDst = (*env)->NewIntArray(env, numPixels);
+  unsigned char *src = (*env)->GetPrimitiveArrayCritical(env, jSrc, 0);
+  unsigned char *colormap = (*env)->GetPrimitiveArrayCritical(env, jColormap, 0);
   unsigned int *dst = (*env)->GetPrimitiveArrayCritical(env, jDst, 0);
   unsigned int *dstPtr = dst;
   unsigned char *srcPtr = src;
 
-  // Create INT_ARGB colormap
-  intARGBColormap = malloc(cmapSize*sizeof(int));
   // Fill it
   toIntARGB(colormap, intARGBColormap, cmapSize);
 
@@ -266,11 +264,11 @@
     *(dstPtr++) = intARGBColormap[*(srcPtr++)];
   }
 
-  free(intARGBColormap);
-  
-  (*env)->ReleasePrimitiveArrayCritical(env, jSrc, src, 0);
   (*env)->ReleasePrimitiveArrayCritical(env, jDst, dst, 0);
-  (*env)->ReleasePrimitiveArrayCritical(env, jColormap, colormap, 0);
+  (*env)->ReleasePrimitiveArrayCritical(env, jSrc, src, JNI_ABORT); /* We does not change this array */
+  (*env)->ReleasePrimitiveArrayCritical(env, jColormap, colormap, JNI_ABORT); /* We does not change this array */
+  
+  free(intARGBColormap);  
 
   return jDst;
 }