[Xquartz-changes] xserver: Branch 'server-1.6-apple' - 3 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Jan 11 15:43:22 PST 2010


 hw/xquartz/mach-startup/bundle-main.c |   36 ++++++++++++++++++++--------------
 hw/xquartz/mach-startup/stub.c        |   13 ++++++++----
 hw/xquartz/pbproxy/Makefile.am        |    3 ++
 hw/xquartz/xpr/x-hook.c               |   12 +++++++++--
 hw/xquartz/xpr/xprCursor.c            |   13 +++++++++---
 5 files changed, 54 insertions(+), 23 deletions(-)

New commits:
commit a0dc5bae963d949f21b727c11a49670323dc621e
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 9 18:27:31 2009 -0800

    XQuartz: pbproxy: Fix building of standalone xpbproxy executable
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at freedesktop.org>
    (cherry picked from commit 97a6454ea57587db490873fee8ff0f899882972d)

diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index e1c537f..02da6b2 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -15,6 +15,9 @@ if STANDALONE_XPBPROXY
 bin_PROGRAMS = xpbproxy
 xpbproxy_SOURCES = app-main.m
 xpbproxy_LDADD = libxpbproxy.la
+xpbproxy_LDFLAGS = -Wl,-framework,Cocoa
+
+AM_CPPFLAGS += -DSTANDALONE_XPBPROXY
 
 endif
 
commit 1bf41121f9b856fd7662a93f2fe6591ab4ac8bfa
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Nov 30 11:03:59 2009 -0800

    XQuartz: Drop calls to alloca
    
    This makes us more consistent with the rest of the codebase, using xalloc/xfree
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at freedesktop.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit f4fc3406720410e37a2bce1b782cba0f0b734e42)

diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index dcba6b2..539894f 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -306,12 +306,12 @@ int main(int argc, char **argv, char **envp) {
     /* We have fixed-size string lengths due to limitations in IPC,
      * so we need to copy our argv and envp.
      */
-    newargv = (string_array_t)alloca(argc * sizeof(string_t));
-    newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
-    
+    newargv = (string_array_t)malloc(argc * sizeof(string_t));
+    newenvp = (string_array_t)malloc(envpc * sizeof(string_t));
+
     if(!newargv || !newenvp) {
         fprintf(stderr, "Xquartz: Memory allocation failure\n");
-        exit(EXIT_FAILURE);
+        return EXIT_FAILURE;
     }
     
     for(i=0; i < argc; i++) {
@@ -322,6 +322,10 @@ int main(int argc, char **argv, char **envp) {
     }
 
     kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
+
+    free(newargv);
+    free(newenvp);
+
     if (kr != KERN_SUCCESS) {
         fprintf(stderr, "Xquartz: start_x11_server: %s\n", mach_error_string(kr));
         return EXIT_FAILURE;
diff --git a/hw/xquartz/xpr/x-hook.c b/hw/xquartz/xpr/x-hook.c
index bb873bb..03e7f85 100644
--- a/hw/xquartz/xpr/x-hook.c
+++ b/hw/xquartz/xpr/x-hook.c
@@ -34,6 +34,7 @@
 #include "x-hook.h"
 #include <stdlib.h>
 #include <assert.h>
+#include "os.h"
 
 #define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d))
 #define CELL_FREE(c)  X_PFX (list_free_1) (c)
@@ -79,9 +80,13 @@ X_PFX (hook_run) (x_list *lst, void *arg)
     int length, i;
 
     length = X_PFX (list_length) (lst);
-    fun = alloca (sizeof (x_hook_function *) * length);
-    data = alloca (sizeof (void *) * length);
+    fun = xalloc (sizeof (x_hook_function *) * length);
+    data = xalloc (sizeof (void *) * length);
 
+    if(!fun || !data) {
+        FatalError("Failed to allocate memory in %s\n", __func__);
+    }
+    
     for (i = 0, node = lst; node != NULL; node = node->next, i++)
     {
 	cell = node->data;
@@ -93,6 +98,9 @@ X_PFX (hook_run) (x_list *lst, void *arg)
     {
 	(*fun[i]) (arg, data[i]);
     }
+    
+    xfree(fun);
+    xfree(data);
 }
 
 X_EXTERN void
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index 4345bee..3025c36 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -95,7 +95,10 @@ load_cursor(CursorPtr src, int screen)
         const uint32_t *be_data=(uint32_t *) src->bits->argb;
         unsigned i;
         rowbytes = src->bits->width * sizeof (CARD32);
-        data=alloca (rowbytes * src->bits->height);
+        data = xalloc(rowbytes * src->bits->height);
+        if(!data) {
+            FatalError("Failed to allocate memory in %s\n", __func__);
+        }
         for(i=0;i<(src->bits->width*src->bits->height);i++)
             data[i]=ntohl(be_data[i]);
 #endif
@@ -118,8 +121,11 @@ load_cursor(CursorPtr src, int screen)
 
         /* round up to 8 pixel boundary so we can convert whole bytes */
         rowbytes = ((src->bits->width * 4) + 31) & ~31;
-        data = alloca(rowbytes * src->bits->height);
-
+        data = xalloc(rowbytes * src->bits->height);
+        if(!data) {
+            FatalError("Failed to allocate memory in %s\n", __func__);
+        }
+        
         if (!src->bits->emptyMask)
         {
             ycount = src->bits->height;
@@ -168,6 +174,7 @@ load_cursor(CursorPtr src, int screen)
     }
 
     err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
+    xfree(data);
     return err == Success;
 }
 
commit 5341aa195f8105032c01b977f226f135f9431fc2
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Nov 23 16:33:00 2009 -0800

    XQuartz: Allow better compatability with older versions of xinit
    
    If we are id="org.x" and the launchd socket is ":0", we will claim
    the socket to match the old behavior before we prefixed the
    socket name with our id.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at freedesktop.org>
    (cherry picked from commit 4677b5a80025b50ba2a3e953fd487a549586ae9f)

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 640a91f..0366f3b 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -333,8 +333,10 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
     /* If we didn't get handed a launchd DISPLAY socket, we should
      * unset DISPLAY or we can run into problems with pbproxy
      */
-    if(!launchd_socket_handed_off)
+    if(!launchd_socket_handed_off) {
+        fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n");
         unsetenv("DISPLAY");
+    }
     
     if(!_argv || !_envp) {
         return KERN_FAILURE;
@@ -473,7 +475,7 @@ static void setup_env(void) {
 
     server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
     if(!server_bootstrap_name) {
-        fprintf(stderr, "Memory allocation error.\n");
+        fprintf(stderr, "X11.app: Memory allocation error.\n");
         exit(1);
     }
     strcpy(server_bootstrap_name, pds);
@@ -482,7 +484,7 @@ static void setup_env(void) {
     len = strlen(server_bootstrap_name);
     launchd_id_prefix = malloc(sizeof(char) * (len - 3));
     if(!launchd_id_prefix) {
-        fprintf(stderr, "Memory allocation error.\n");
+        fprintf(stderr, "X11.app: Memory allocation error.\n");
         exit(1);
     }
     strlcpy(launchd_id_prefix, server_bootstrap_name, len - 3);
@@ -497,21 +499,27 @@ static void setup_env(void) {
         }
 
         if(s && *s) {
-            temp = (char *)malloc(sizeof(char) * len);
-            if(!temp) {
-                fprintf(stderr, "Memory allocation error creating space for socket name test.\n");
-                exit(1);
-            }
-            strlcpy(temp, launchd_id_prefix, len);
-            strlcat(temp, ":0", len);
+            if(strcmp(launchd_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
+                fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
+            } else {
+                temp = (char *)malloc(sizeof(char) * len);
+                if(!temp) {
+                    fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n");
+                    exit(1);
+                }
+                strlcpy(temp, launchd_id_prefix, len);
+                strlcat(temp, ":0", len);
             
-            if(strcmp(temp, s) != 0) {
-                /* If we don't have a match, unset it. */
-                unsetenv("DISPLAY");
+                if(strcmp(temp, s) != 0) {
+                    /* If we don't have a match, unset it. */
+                    fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, launchd_id_prefix);
+                    unsetenv("DISPLAY");
+                }
+                free(temp);
             }
-            free(temp);
         } else {
             /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
+            fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
             unsetenv("DISPLAY");
         }
     }
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 3d22db5..dcba6b2 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -232,6 +232,7 @@ int main(int argc, char **argv, char **envp) {
 
     kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
     if(kr != KERN_SUCCESS) {
+        fprintf(stderr, "Xquartz: Unable to locate waiting server: %s\n", server_bootstrap_name);
         pid_t child;
         set_x11_path();
 


More information about the Xquartz-changes mailing list