diff options
| author | Richard M. Stallman | 1997-01-07 23:52:21 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-01-07 23:52:21 +0000 |
| commit | 49b6d120a67691348e884015dd2c343bd1a0d954 (patch) | |
| tree | 2937bedda868b2b6be27f5fd29817222439e8e19 | |
| parent | 1ac95fabf3692f7b5bb184091e52ee7152ce14dd (diff) | |
| download | emacs-49b6d120a67691348e884015dd2c343bd1a0d954.tar.gz emacs-49b6d120a67691348e884015dd2c343bd1a0d954.zip | |
(LOCK_PID_MAX): Use sizeof (unsigned long) instead of hardwiring 21.
(lock_file_1): Use LOCK_PID_MAX when allocating lock_info_str
instead of hardwiring 21.
| -rw-r--r-- | src/filelock.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/filelock.c b/src/filelock.c index 25ab59eb25b..743b8d0e595 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -89,8 +89,9 @@ typedef struct | |||
| 89 | unsigned long pid; | 89 | unsigned long pid; |
| 90 | } lock_info_type; | 90 | } lock_info_type; |
| 91 | 91 | ||
| 92 | /* When we read the info back, we might need this much more. */ | 92 | /* When we read the info back, we might need this much more, |
| 93 | #define LOCK_PID_MAX 21 /* enough for signed 64 bits plus null */ | 93 | enough for decimal representation plus null. */ |
| 94 | #define LOCK_PID_MAX (4 * sizeof (unsigned long)) | ||
| 94 | 95 | ||
| 95 | /* Free the two dynamically-allocated pieces in PTR. */ | 96 | /* Free the two dynamically-allocated pieces in PTR. */ |
| 96 | #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0) | 97 | #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0) |
| @@ -134,7 +135,8 @@ lock_file_1 (lfname, force) | |||
| 134 | register int err; | 135 | register int err; |
| 135 | char *user_name = XSTRING (Fuser_login_name (Qnil))->data; | 136 | char *user_name = XSTRING (Fuser_login_name (Qnil))->data; |
| 136 | char *host_name = XSTRING (Fsystem_name ())->data; | 137 | char *host_name = XSTRING (Fsystem_name ())->data; |
| 137 | char *lock_info_str = alloca (strlen (user_name) + strlen (host_name) + 21); | 138 | char *lock_info_str = alloca (strlen (user_name) + strlen (host_name) |
| 139 | + LOCK_PID_MAX + 5); | ||
| 138 | 140 | ||
| 139 | sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name, | 141 | sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name, |
| 140 | (unsigned long) getpid ()); | 142 | (unsigned long) getpid ()); |