]> git.imager.perl.org - imager.git/blobdiff - dynaload.c
- implement/test/document set_file_limits()/get_file_limits() methods,
[imager.git] / dynaload.c
index 28b646c3486c34531b1bf35c90f963f4e23e5f77..1d308fd721f2cb1cd9d5ce71657caa03f215dd50 100644 (file)
@@ -1,3 +1,4 @@
+#include "image.h"
 #include "dynaload.h"
 /* #include "XSUB.h"  so we can compile on threaded perls */
 #include "imagei.h"
@@ -5,7 +6,7 @@
 static symbol_table_t symbol_table={i_has_format,ICL_set_internal,ICL_info,
                             i_img_new,i_img_empty,i_img_empty_ch,i_img_exorcise,
                             i_img_info,i_img_setmask,i_img_getmask,
-                            i_box,i_draw,i_arc,i_copyto,i_copyto_trans,i_rubthru};
+                            i_box,i_line,i_arc,i_copyto,i_copyto_trans,i_rubthru};
 
 
 /*
@@ -56,11 +57,14 @@ DSO_open(char* file,char** evalstring) {
   mm_log( (1,"Call ok.\n") ); 
  
   if ( (shl_findsym(&tt_handle, I_FUNCTION_LIST ,TYPE_UNDEFINED,(func_ptr*)&function_list))) return NULL; 
-  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) return NULL;
+  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) /* checked 17jul05 tonyc */
+    return NULL;
 
   dso_handle->handle=tt_handle; /* needed to close again */
   dso_handle->function_list=function_list;
-  if ( (dso_handle->filename=(char*)malloc(strlen(file))) == NULL) { free(dso_handle); return NULL; }
+  if ( (dso_handle->filename=(char*)malloc(strlen(file)+1)) == NULL) { /* checked 17jul05 tonyc */
+    free(dso_handle); return NULL;
+  }
   strcpy(dso_handle->filename,file);
 
   mm_log((1,"DSO_open <- (0x%X)\n",dso_handle));
@@ -110,14 +114,18 @@ DSO_open(char *file, char **evalstring) {
     FreeLibrary(d_handle);
     return NULL;
   }
-  if ( (dso_handle = (DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) {
+  if ( (dso_handle = (DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) { /* checked 17jul05 tonyc */
     mm_log( (1, "DSO_Open: out of memory\n") );
     FreeLibrary(d_handle);
     return NULL;
   }
   dso_handle->handle=d_handle; /* needed to close again */
   dso_handle->function_list=function_list;
-  if ( (dso_handle->filename=(char*)malloc(strlen(file))) == NULL) { free(dso_handle); FreeLibrary(d_handle); return NULL; }
+  if ( (dso_handle->filename=(char*)malloc(strlen(file)+1)) == NULL) { /* checked 17jul05 tonyc */
+    free(dso_handle);
+    FreeLibrary(d_handle); 
+    return NULL; 
+  }
   strcpy(dso_handle->filename,file);
 
   mm_log( (1,"DSO_open <- 0x%X\n",dso_handle) );
@@ -128,9 +136,11 @@ DSO_open(char *file, char **evalstring) {
 undef_int
 DSO_close(void *ptr) {
   DSO_handle *handle = (DSO_handle *)ptr;
-  FreeLibrary(handle->handle);
+  BOOL result = FreeLibrary(handle->handle);
   free(handle->filename);
   free(handle);
+
+  return result;
 }
 
 #else
@@ -284,11 +294,15 @@ DSO_open(char* file,char** evalstring) {
     return NULL;
   }
   
-  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) return NULL;
+  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) /* checked 17jul05 tonyc */
+    return NULL;
   
   dso_handle->handle=d_handle; /* needed to close again */
   dso_handle->function_list=function_list;
-  if ( (dso_handle->filename=(char*)malloc(strlen(file))) == NULL) { free(dso_handle); return NULL; }
+  if ( (dso_handle->filename=(char*)malloc(strlen(file)+1)) == NULL) { /* checked 17jul05 tonyc */
+    free(dso_handle); 
+    return NULL;
+  }
   strcpy(dso_handle->filename,file);
 
   mm_log( (1,"DSO_open <- 0x%X\n",dso_handle) );