summaryrefslogtreecommitdiff
path: root/src/filelock.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2012-07-10 10:23:45 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2012-07-10 10:23:45 +0400
commitc293e30cd9f841e59ce6ae3b2757f0e6daf2e71d (patch)
tree6aaff4b91e43d732c4a7dea94ba3bf28a94b2955 /src/filelock.c
parentaf6e839f9fadf33b22c145d3103f6e3d9656e804 (diff)
downloademacs-c293e30cd9f841e59ce6ae3b2757f0e6daf2e71d.tar.gz
emacs-c293e30cd9f841e59ce6ae3b2757f0e6daf2e71d.tar.bz2
emacs-c293e30cd9f841e59ce6ae3b2757f0e6daf2e71d.zip
Avoid calls to strlen in path processing functions.
* fileio.c (file_name_as_directory): Add comment. Change to add srclen argument and return the length of result. Adjust users accordingly. (directory_file_name): Fix comment. Change to add srclen argument, swap 1nd and 2st arguments to obey the common convention. Adjust users accordingly. * filelock.c (fill_in_lock_file_name): Avoid calls to strlen.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 30258a5ffa0..e5de7355652 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -300,6 +300,7 @@ typedef struct
static void
fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
{
+ ptrdiff_t length = SBYTES (fn);
register char *p;
struct stat st;
int count = 0;
@@ -309,14 +310,14 @@ fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
/* Shift the nondirectory part of the file name (including the null)
right two characters. Here is one of the places where we'd have to
do something to support 14-character-max file names. */
- for (p = lockfile + strlen (lockfile); p != lockfile && *p != '/'; p--)
+ for (p = lockfile + length; p != lockfile && *p != '/'; p--)
p[2] = *p;
/* Insert the `.#'. */
p[1] = '.';
p[2] = '#';
- p = p + strlen (p);
+ p = p + length + 2;
while (lstat (lockfile, &st) == 0 && !S_ISLNK (st.st_mode))
{