[57441] trunk/base/src/macports1.0/realpath.c
jmr at macports.org
jmr at macports.org
Thu Sep 10 23:58:15 PDT 2009
Revision: 57441
http://trac.macports.org/changeset/57441
Author: jmr at macports.org
Date: 2009-09-10 23:58:14 -0700 (Thu, 10 Sep 2009)
Log Message:
-----------
realpath only allocates memory for you on 10.6
Modified Paths:
--------------
trunk/base/src/macports1.0/realpath.c
Modified: trunk/base/src/macports1.0/realpath.c
===================================================================
--- trunk/base/src/macports1.0/realpath.c 2009-09-11 06:54:31 UTC (rev 57440)
+++ trunk/base/src/macports1.0/realpath.c 2009-09-11 06:58:14 UTC (rev 57441)
@@ -37,6 +37,7 @@
#include <tcl.h>
#include <errno.h>
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
@@ -54,7 +55,8 @@
const char error_message[] = "realpath failed: ";
Tcl_Obj *tcl_result;
char *path;
- char *rpath;
+ char *rpath = malloc(PATH_MAX+1);
+ char *res;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "path");
@@ -62,8 +64,9 @@
}
path = Tcl_GetString(objv[1]);
- rpath = realpath(path, NULL);
- if (!rpath) {
+ res = realpath(path, rpath);
+ if (!res) {
+ free(rpath);
tcl_result = Tcl_NewStringObj(error_message, sizeof(error_message) - 1);
Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(strerror(errno), -1));
Tcl_SetObjResult(interp, tcl_result);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090910/bed5d94d/attachment.html>
More information about the macports-changes
mailing list