]> git.eshelyaron.com Git - emacs.git/commitdiff
(LOCK_PID_MAX): Use sizeof (unsigned long) instead of hardwiring 21.
authorRichard M. Stallman <rms@gnu.org>
Tue, 7 Jan 1997 23:52:21 +0000 (23:52 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 7 Jan 1997 23:52:21 +0000 (23:52 +0000)
(lock_file_1): Use LOCK_PID_MAX when allocating lock_info_str
instead of hardwiring 21.

src/filelock.c

index 25ab59eb25b3c4f4c08281463c7d381ff704a954..743b8d0e59527613d64f22a958f4bffbe693e489 100644 (file)
@@ -89,8 +89,9 @@ typedef struct
   unsigned long pid;
 } lock_info_type;
 
-/* When we read the info back, we might need this much more.  */
-#define LOCK_PID_MAX 21 /* enough for signed 64 bits plus null */
+/* When we read the info back, we might need this much more,
+   enough for decimal representation plus null.  */
+#define LOCK_PID_MAX (4 * sizeof (unsigned long))
 
 /* Free the two dynamically-allocated pieces in PTR.  */
 #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0)
@@ -134,7 +135,8 @@ lock_file_1 (lfname, force)
   register int err;
   char *user_name = XSTRING (Fuser_login_name (Qnil))->data;
   char *host_name = XSTRING (Fsystem_name ())->data;
-  char *lock_info_str = alloca (strlen (user_name) + strlen (host_name) + 21);
+  char *lock_info_str = alloca (strlen (user_name) + strlen (host_name)
+                                + LOCK_PID_MAX + 5);
 
   sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
            (unsigned long) getpid ());