[81761] branches/gsoc11-rev-upgrade/base/src/machista1.0

cal at macports.org cal at macports.org
Thu Aug 4 11:08:54 PDT 2011


Revision: 81761
          http://trac.macports.org/changeset/81761
Author:   cal at macports.org
Date:     2011-08-04 11:08:54 -0700 (Thu, 04 Aug 2011)
Log Message:
-----------
rev-upgrade: Move definition of machista::get_arch_name above typemap free()ing the return value, which would cause a crash

Modified Paths:
--------------
    branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i
    branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c

Modified: branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i	2011-08-04 18:05:04 UTC (rev 81760)
+++ branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i	2011-08-04 18:08:54 UTC (rev 81761)
@@ -140,6 +140,15 @@
 const char *macho_strerror(int err);
 
 /**
+ * map macho_get_arch_name()
+ * The memory for the returned char * comes from NXGetArchInfoFromCpuType(),
+ * which is documentet in arch(3), without ever mentioning any memory issues. I
+ * assume it's static memory, that should not be free()'d.
+ */
+%rename(get_arch_name) macho_get_arch_name;
+const char *macho_get_arch_name(cpu_type_t);
+
+/**
  * map macho_format_dylib_version()
  * Since this function internally allocates the result and returns an allocated
  * pointer, it needs to be free()'d after usage (in this case usage is
@@ -151,12 +160,3 @@
 %rename(format_dylib_version) macho_format_dylib_version;
 char *macho_format_dylib_version(uint32_t);
 
-/**
- * map macho_get_arch_name()
- * The memory for the returned char * comes from NXGetArchInfoFromCpuType(),
- * which is documentet in arch(3), without ever mentioning any memory issues. I
- * assume it's static memory, that should not be free()'d.
- */
-%rename(get_arch_name) macho_get_arch_name;
-const char *macho_get_arch_name(cpu_type_t);
-

Modified: branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c	2011-08-04 18:05:04 UTC (rev 81760)
+++ branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c	2011-08-04 18:08:54 UTC (rev 81761)
@@ -2269,23 +2269,20 @@
 
 
 SWIGINTERN int
-_wrap_format_dylib_version(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
-  uint32_t arg1 ;
-  unsigned int val1 ;
+_wrap_get_arch_name(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
+  cpu_type_t arg1 ;
+  int val1 ;
   int ecode1 = 0 ;
   char *result = 0 ;
   
-  if (SWIG_GetArgs(interp, objc, objv,"o:machista::format_dylib_version uint32_t ",(void *)0) == TCL_ERROR) SWIG_fail;
-  ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1);
+  if (SWIG_GetArgs(interp, objc, objv,"o:machista::get_arch_name cpu_type_t ",(void *)0) == TCL_ERROR) SWIG_fail;
+  ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "format_dylib_version" "', argument " "1"" of type '" "uint32_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "get_arch_name" "', argument " "1"" of type '" "cpu_type_t""'");
   } 
-  arg1 = (uint32_t)(val1);
-  result = (char *)macho_format_dylib_version(arg1);
+  arg1 = (cpu_type_t)(val1);
+  result = (char *)macho_get_arch_name(arg1);
   Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)result));
-  {
-    free(result);
-  }
   return TCL_OK;
 fail:
   return TCL_ERROR;
@@ -2293,19 +2290,19 @@
 
 
 SWIGINTERN int
-_wrap_get_arch_name(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
-  cpu_type_t arg1 ;
-  int val1 ;
+_wrap_format_dylib_version(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
+  uint32_t arg1 ;
+  unsigned int val1 ;
   int ecode1 = 0 ;
   char *result = 0 ;
   
-  if (SWIG_GetArgs(interp, objc, objv,"o:machista::get_arch_name cpu_type_t ",(void *)0) == TCL_ERROR) SWIG_fail;
-  ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1);
+  if (SWIG_GetArgs(interp, objc, objv,"o:machista::format_dylib_version uint32_t ",(void *)0) == TCL_ERROR) SWIG_fail;
+  ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "get_arch_name" "', argument " "1"" of type '" "cpu_type_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "format_dylib_version" "', argument " "1"" of type '" "uint32_t""'");
   } 
-  arg1 = (cpu_type_t)(val1);
-  result = (char *)macho_get_arch_name(arg1);
+  arg1 = (uint32_t)(val1);
+  result = (char *)macho_format_dylib_version(arg1);
   Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)result));
   {
     free(result);
@@ -2339,8 +2336,8 @@
     { SWIG_prefix "destroy_handle", (swig_wrapper_func) _wrap_destroy_handle, NULL},
     { SWIG_prefix "parse_file", (swig_wrapper_func) _wrap_parse_file, NULL},
     { SWIG_prefix "strerror", (swig_wrapper_func) _wrap_strerror, NULL},
-    { SWIG_prefix "format_dylib_version", (swig_wrapper_func) _wrap_format_dylib_version, NULL},
     { SWIG_prefix "get_arch_name", (swig_wrapper_func) _wrap_get_arch_name, NULL},
+    { SWIG_prefix "format_dylib_version", (swig_wrapper_func) _wrap_format_dylib_version, NULL},
     {0, 0, 0}
 };
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110804/f6ce2760/attachment.html>


More information about the macports-changes mailing list