Mercurial > hg > xemacs-beta
comparison src/filelock.c @ 1726:a8d8f419b459
[xemacs-hg @ 2003-09-30 15:26:34 by james]
Add type information to xfree to avoid alias creation.
author | james |
---|---|
date | Tue, 30 Sep 2003 15:27:01 +0000 |
parents | 804517e16990 |
children | ecf1ebac70d8 |
comparison
equal
deleted
inserted
replaced
1725:7ff8f4d70aec | 1726:a8d8f419b459 |
---|---|
86 /* When we read the info back, we might need this much more, | 86 /* When we read the info back, we might need this much more, |
87 enough for decimal representation plus null. */ | 87 enough for decimal representation plus null. */ |
88 #define LOCK_PID_MAX (4 * sizeof (pid_t)) | 88 #define LOCK_PID_MAX (4 * sizeof (pid_t)) |
89 | 89 |
90 /* Free the two dynamically-allocated pieces in PTR. */ | 90 /* Free the two dynamically-allocated pieces in PTR. */ |
91 #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0) | 91 #define FREE_LOCK_INFO(i) do { \ |
92 xfree ((i).user, Ibyte *); \ | |
93 xfree ((i).host, Ibyte *); \ | |
94 } while (0) | |
92 | 95 |
93 /* Write the name of the lock file for FN into LFNAME. Length will be | 96 /* Write the name of the lock file for FN into LFNAME. Length will be |
94 that of FN plus two more for the leading `.#' plus one for the null. */ | 97 that of FN plus two more for the leading `.#' plus one for the null. */ |
95 #define MAKE_LOCK_NAME(lock, file) \ | 98 #define MAKE_LOCK_NAME(lock, file) \ |
96 (lock = (Ibyte *) ALLOCA (XSTRING_LENGTH (file) + 2 + 1), \ | 99 (lock = (Ibyte *) ALLOCA (XSTRING_LENGTH (file) + 2 + 1), \ |
178 while (len >= bufsize); | 181 while (len >= bufsize); |
179 | 182 |
180 /* If nonexistent lock file, all is well; otherwise, got strange error. */ | 183 /* If nonexistent lock file, all is well; otherwise, got strange error. */ |
181 if (len == -1) | 184 if (len == -1) |
182 { | 185 { |
183 xfree (lfinfo); | 186 xfree (lfinfo, Ibyte *); |
184 return errno == ENOENT ? 0 : -1; | 187 return errno == ENOENT ? 0 : -1; |
185 } | 188 } |
186 | 189 |
187 /* Link info exists, so `len' is its length. Null terminate. */ | 190 /* Link info exists, so `len' is its length. Null terminate. */ |
188 lfinfo[len] = 0; | 191 lfinfo[len] = 0; |
198 /* Parse USER@HOST.PID. If can't parse, return -1. */ | 201 /* Parse USER@HOST.PID. If can't parse, return -1. */ |
199 /* The USER is everything before the first @. */ | 202 /* The USER is everything before the first @. */ |
200 at = qxestrchr (lfinfo, '@'); | 203 at = qxestrchr (lfinfo, '@'); |
201 dot = qxestrrchr (lfinfo, '.'); | 204 dot = qxestrrchr (lfinfo, '.'); |
202 if (!at || !dot) { | 205 if (!at || !dot) { |
203 xfree (lfinfo); | 206 xfree (lfinfo, Ibyte *); |
204 return -1; | 207 return -1; |
205 } | 208 } |
206 len = at - lfinfo; | 209 len = at - lfinfo; |
207 owner->user = (Ibyte *) xmalloc (len + 1); | 210 owner->user = (Ibyte *) xmalloc (len + 1); |
208 qxestrncpy (owner->user, lfinfo, len); | 211 qxestrncpy (owner->user, lfinfo, len); |
216 owner->host = (Ibyte *) xmalloc (len + 1); | 219 owner->host = (Ibyte *) xmalloc (len + 1); |
217 qxestrncpy (owner->host, at + 1, len); | 220 qxestrncpy (owner->host, at + 1, len); |
218 owner->host[len] = 0; | 221 owner->host[len] = 0; |
219 | 222 |
220 /* We're done looking at the link info. */ | 223 /* We're done looking at the link info. */ |
221 xfree (lfinfo); | 224 xfree (lfinfo, Ibyte *); |
222 | 225 |
223 /* On current host? */ | 226 /* On current host? */ |
224 if (STRINGP (Fsystem_name ()) | 227 if (STRINGP (Fsystem_name ()) |
225 && qxestrcmp (owner->host, XSTRING_DATA (Fsystem_name ())) == 0) | 228 && qxestrcmp (owner->host, XSTRING_DATA (Fsystem_name ())) == 0) |
226 { | 229 { |