1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

save_textarea_file(): do not open file for writing if not needed. Patch

by Alexey Tourbin.
This commit is contained in:
Laurent MONIN 2007-03-05 21:48:42 +01:00 committed by Laurent MONIN
parent ecce8bfa91
commit 86686983c0

View File

@ -534,7 +534,7 @@ save_textarea_file(unsigned char *value)
unsigned char *filename;
FILE *fp = NULL;
int fd;
size_t nmemb;
size_t nmemb, len;
filename = get_tempdir_filename("elinks-area-XXXXXX");
if (!filename) return NULL;
@ -545,6 +545,9 @@ save_textarea_file(unsigned char *value)
return NULL;
}
len = strlen(value);
if (len == 0) return filename;
fp = fdopen(fd, "w");
if (!fp) {
@ -555,7 +558,7 @@ error:
return NULL;
}
nmemb = fwrite(value, strlen(value), 1, fp);
nmemb = fwrite(value, len, 1, fp);
if (nmemb != 1) {
fclose(fp);
goto error;