use xmalloc_atomic for many pointerless objects
[bpt/emacs.git] / src / xsmfns.c
index 289aac8..645e199 100644 (file)
@@ -1,7 +1,7 @@
 /* Session management module for systems which understand the X Session
    management protocol.
 
-Copyright (C) 2002-201 Free Software Foundation, Inc.
+Copyright (C) 2002-2014 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -107,8 +107,7 @@ x_session_check_input (int fd, void *data)
      will be called.  */
   emacs_event.kind = NO_EVENT;
 
-  ret = IceProcessMessages (SmcGetIceConnection (smc_conn),
-                            (IceReplyWaitInfo *)0, (Bool *)0);
+  ret = IceProcessMessages (SmcGetIceConnection (smc_conn), 0, 0);
   if (ret != IceProcessMessagesSuccess)
     {
       /* Either IO error or Connection closed.  */
@@ -211,7 +210,7 @@ smc_save_yourself_CB (SmcConn smcConn,
       props[props_idx]->num_vals = 1;
       props[props_idx]->vals = &values[val_idx++];
       props[props_idx]->vals[0].length = strlen (cwd);
-      props[props_idx]->vals[0].value = cwd;
+      props[props_idx]->vals[0].value = xstrdup (cwd);
       ++props_idx;
     }
 
@@ -230,7 +229,7 @@ smc_save_yourself_CB (SmcConn smcConn,
   props[props_idx]->vals[vp_idx].length = strlen (emacs_program);
   props[props_idx]->vals[vp_idx++].value = emacs_program;
 
-  smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1);
+  smid_opt = xmalloc_atomic (strlen (SMID_OPT) + strlen (client_id) + 1);
   strcpy (smid_opt, SMID_OPT);
   strcat (smid_opt, client_id);
 
@@ -242,7 +241,7 @@ smc_save_yourself_CB (SmcConn smcConn,
 
   if (cwd)
     {
-      chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1);
+      chdir_opt = xmalloc_atomic (strlen (CHDIR_OPT) + strlen (cwd) + 1);
       strcpy (chdir_opt, CHDIR_OPT);
       strcat (chdir_opt, cwd);
 
@@ -262,7 +261,7 @@ smc_save_yourself_CB (SmcConn smcConn,
 
   xfree (smid_opt);
   xfree (chdir_opt);
-  xfree (cwd);
+  free (cwd);
   xfree (vp);
 
   for (i = 0; i < props_idx; ++i)
@@ -396,7 +395,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
 {
 #define SM_ERRORSTRING_LEN 512
   char errorstring[SM_ERRORSTRING_LEN];
-  charprevious_id = NULL;
+  char *previous_id = NULL;
   SmcCallbacks callbacks;
   ptrdiff_t name_len = 0;
 
@@ -415,7 +414,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
 
   /* This malloc will not be freed, but it is only done once, and hopefully
      not very large   */
-  emacs_program = xmalloc (name_len + 1);
+  emacs_program = xmalloc_atomic (name_len + 1);
   emacs_program[0] = '\0';
 
   if (! EQ (Vinvocation_directory, Qnil))
@@ -514,9 +513,11 @@ Do not call this function yourself. */)
          prevent.  Fix this in next version.  */
       Fkill_emacs (Qnil);
 
+#if 0
       /* This will not be reached, but we want kill-emacs-hook to be run.  */
       SmcCloseConnection (smc_conn, 0, 0);
       ice_connection_closed ();
+#endif
     }
 
   return Qnil;