harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r532383 - /harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/gifdecoder.c
Date Wed, 25 Apr 2007 15:13:42 GMT
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;
 }



Mime
View raw message