[57437] users/toby/objcports/MPPort.c

toby at macports.org toby at macports.org
Thu Sep 10 23:37:42 PDT 2009


Revision: 57437
          http://trac.macports.org/changeset/57437
Author:   toby at macports.org
Date:     2009-09-10 23:37:39 -0700 (Thu, 10 Sep 2009)
Log Message:
-----------
simplify

Modified Paths:
--------------
    users/toby/objcports/MPPort.c

Modified: users/toby/objcports/MPPort.c
===================================================================
--- users/toby/objcports/MPPort.c	2009-09-11 06:24:27 UTC (rev 57436)
+++ users/toby/objcports/MPPort.c	2009-09-11 06:37:39 UTC (rev 57437)
@@ -26,6 +26,7 @@
 static CFStringRef kPortVariableCallback = CFSTR("Callback");
 
 static void command_create(Tcl_Interp *interp, const char *cmdName, ClientData clientData);
+static void command_create_cf(Tcl_Interp *interp, CFStringRef cmdName, ClientData clientData);
 static char *variable_read(ClientData clientData, Tcl_Interp *interp, const char *name1, const char *name2, int flags);
 static int _nslog(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
 static int _fake_boolean(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
@@ -131,49 +132,35 @@
 		tmparr = mp_port_targets(port);
 		CFArrayApplyBlock2(tmparr, ^(const void *target) {
 			CFStringRef tmp;
-			char *s;
 
-			s = strdup_cf(target);
-			command_create(port->_interp, s, port);
-			free(s);
+			command_create_cf(port->_interp, target, port);
 
 			tmp = CFStringCreateWithFormat(NULL, NULL, CFSTR("pre-%@"), target);
-			s = strdup_cf(tmp);
-			command_create(port->_interp, s, port);
-			free(s);
+			command_create_cf(port->_interp, tmp, port);
 			CFRelease(tmp);
 
 			tmp = CFStringCreateWithFormat(NULL, NULL, CFSTR("post-%@"), target);
-			s = strdup_cf(tmp);
-			command_create(port->_interp, s, port);
-			free(s);
+			command_create_cf(port->_interp, tmp, port);
 			CFRelease(tmp);
 		});
 		CFRelease(tmparr);
 
 		tmparr = mp_port_settable_variables(port);
 		CFArrayApplyBlock2(tmparr, ^(const void *opt) {
-			char *s = strdup_cf(opt);
-			command_create(port->_interp, s, port);
-			free(s);
+			command_create_cf(port->_interp, opt, port);
 		});
 		CFRelease(tmparr);
 
 		tmparr = mp_port_settable_array_variables(port);
 		CFArrayApplyBlock2(tmparr, ^(const void *opt) {
 			CFStringRef tmp;
-			char *s;
 
 			tmp = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@-append"), opt);
-			s = strdup_cf(tmp);
-			command_create(port->_interp, s, port);
-			free(s);
+			command_create_cf(port->_interp, tmp, port);
 			CFRelease(tmp);
 
 			tmp = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@-delete"), opt);
-			s = strdup_cf(tmp);
-			command_create(port->_interp, s, port);
-			free(s);
+			command_create_cf(port->_interp, tmp, port);
 			CFRelease(tmp);
 		});
 		CFRelease(tmparr);
@@ -639,6 +626,14 @@
 	Tcl_CreateObjCommand(interp, cmdName, command_trampoline, clientData, NULL);
 }
 
+static void
+command_create_cf(Tcl_Interp *interp, CFStringRef cmdName, ClientData clientData)
+{
+	char *s = strdup_cf(cmdName);
+	command_create(interp, s, clientData);
+	free(s);
+}
+
 static char *
 variable_read(ClientData clientData, Tcl_Interp *interp, const char *name1, const char *name2, int flags)
 {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090910/323b8b8d/attachment.html>


More information about the macports-changes mailing list