Commits

camlspotter committed a24a1f2

C interface fix

  • Participants
  • Parent commits 8a94210

Comments (0)

Files changed (2)

   r[0] = Val_int( color->Red );
   r[1] = Val_int( color->Green );
   r[2] = Val_int( color->Blue );
-  res = alloc_tuple(3);
+  res = alloc_small(3,0);
   for(i=0; i<3; i++) Field(res, i) = r[i];
 #ifdef DEBUG_GIF
 fprintf(stderr, "Color(%d,%d,%d)\n", color->Red, color->Green, color->Blue);
 
     cmap = alloc_tuple(colorMap->ColorCount);
     for(i= 0; i< colorMap->ColorCount; i++){
-      modify(&Field(cmap,i), Val_GifColorType( &colorMap->Colors[i] ));
+        Store_field(cmap,i, Val_GifColorType( &colorMap->Colors[i] ));
     }
   } else {
 #ifdef DEBUG_GIF
   r[3] = Val_int( imageDesc->Height );
   r[4] = Val_int( imageDesc->Interlace );
   r[5] = Val_ColorMapObject( imageDesc->ColorMap );
-  res = alloc_tuple(6);
+  res = alloc_small(6,0);
   for(i=0; i<6; i++) Field(res, i) = r[i];
   CAMLreturn(res);
 }
   r[2] = Val_int(GifFile->SColorResolution);
   r[3] = Val_int(GifFile->SBackGroundColor);
   r[4] = Val_ColorMapObject(GifFile->SColorMap);
-  res = alloc_tuple(5);
+  res = alloc_small(5,0);
   for(i=0; i<5; i++) Field(res, i) = r[i];
 
   CAMLreturn(res);
 
   r[0] = Val_ScreenInfo( GifFile );
   r[1] = (value) GifFile;
-  res = alloc_tuple(2);
+  res = alloc_small(2,0);
   for(i=0; i<2; i++) Field(res, i) = r[i];
 
   CAMLreturn(res);
 } 
 
-value dGifCloseFile( value hdl )
+void dGifCloseFile( value hdl )
 {
   CAMLparam1(hdl);
 
   ((GifFileType *)hdl)->Image.ColorMap = NULL; 
 
   DGifCloseFile( (GifFileType *) hdl );
-  CAMLreturn(Val_unit);
+  CAMLreturn0;
 }
 
 value dGifGetRecordType( value hdl )
     exts= newres;
     DGifGetExtensionNext(GifFile, &extData);
   }
-  res = alloc_tuple(2);
+  res = alloc_small(2,0);
   Field(res,0) = Val_int(func);
   Field(res,1) = exts;
 
 
 ColorMapObject *ColorMapObject_val( value cmap )
 {
-  CAMLparam1(cmap);
-
+  // no caml allocation inside.
   int len;
   int i;
   ColorMapObject *cmapobj;
 
-  if( cmap == Atom(0) ){ CAMLreturn(NULL); } 
+  if( cmap == Atom(0) ){ return NULL; } 
 
   len = Wosize_val(cmap);
 
     cmapobj->Colors[i].Green = Int_val(Field(Field(cmap,i),1));
     cmapobj->Colors[i].Blue  = Int_val(Field(Field(cmap,i),2));
   }
-  CAMLreturn(cmapobj); 
+  return cmapobj; 
 }
 
 value eGifOpenFileName( name )
   CAMLreturn((value)GifFileOut);
 }
 
-value eGifCloseFile( value hdl )
+void eGifCloseFile( value hdl )
 {
   CAMLparam1(hdl);
 
   ((GifFileType *)hdl)->Image.ColorMap = NULL; 
 
   EGifCloseFile( (GifFileType *) hdl );
-  CAMLreturn(Val_unit);
+  CAMLreturn0;
 }
 
-value eGifPutScreenDesc( value oc, value sdesc )
+void eGifPutScreenDesc( value oc, value sdesc )
 {
   CAMLparam2(oc,sdesc);
 
 			 ColorMapObject_val( Field(sdesc, 4) )) == GIF_ERROR){
     failwith("EGifPutScreenDesc");
   }
-  CAMLreturn(Val_unit);
+  CAMLreturn0;
 }
 
-value eGifPutImageDesc( value oc, value idesc )
+void eGifPutImageDesc( value oc, value idesc )
 {
   CAMLparam2(oc,idesc);
 
 			ColorMapObject_val( Field(idesc, 5) )) == GIF_ERROR){
     failwith("EGifPutImageDesc");
   }
-  CAMLreturn(Val_unit);
+  CAMLreturn0;
 }
 
-value eGifPutLine( value oc, value buf )
+void eGifPutLine( value oc, value buf )
 {
   CAMLparam2(oc,buf);
 
     // PrintGifError ();
     failwith("EGifPutLine");
   }
-  CAMLreturn(Val_unit);
+  CAMLreturn0;
 }
 
-value eGifPutExtension( value oc, value ext )
+void eGifPutExtension( value oc, value ext )
 {
   CAMLparam2(oc,ext);
   CAMLlocal1(l);
     free(extension);
     failwith("EGifPutExtension");
   }
-  CAMLreturn(Val_unit);
+  CAMLreturn0;
 }