[llvm-commits] [vmkit] r51047 - /vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp

Bill Wendling isanbard at gmail.com
Tue May 13 11:07:01 PDT 2008


On Tue, May 13, 2008 at 8:02 AM, Nicolas Geoffray
<nicolas.geoffray at lip6.fr> wrote:
> Author: geoffray
> Date: Tue May 13 10:02:24 2008
> New Revision: 51047
>
> URL: http://llvm.org/viewvc/llvm-project?rev=51047&view=rev
> Log:
> Darwin requires to preallocate rp.
>
>
> Modified:
>    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
>
> Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
> URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=51047&r1=51046&r2=51047&view=diff
>
> ==============================================================================
> --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
> +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Tue May 13 10:02:24 2008
> @@ -125,7 +125,6 @@
>     char* buf = (char*)alloca(len + 1);
>     const char* cur = str;
>     int top = 0;
> -    char* rp = 0;
>     char c = 1;
>     while (c != 0) {
>       while (((c = cur[top]) != 0) && c != envSeparator[0]) {
> @@ -134,8 +133,10 @@
>       if (top != 0) {
>         memcpy(buf, cur, top);
>         buf[top] = 0;
> +        char* rp = (char*)malloc(4096);
> +        memset(rp, 0, 4096);

Instead of these magic numbers, could you use either a #define or enum
and comment why you're using that value?

-bw

>         rp = realpath(buf, rp);
> -        if (rp != 0) {
> +        if (rp[4095] == 0 && strlen(rp) != 0) {
>           struct stat st;
>           stat(rp, &st);
>           if ((st.st_mode & S_IFMT) == S_IFDIR) {
> @@ -145,9 +146,12 @@
>             temp[len] = dirSeparator[0];
>             temp[len + 1] = 0;
>             bootClasspath.push_back(temp);
> +            free(rp);
>           } else {
>             bootClasspath.push_back(rp);
>           }
> +        } else {
> +          free(rp);
>         }
>       }
>       cur = cur + top + 1;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list