summaryrefslogtreecommitdiff
path: root/lib/file.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-08-04 19:34:16 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-08-12 13:17:57 +0200
commit4ad8e142da463ab208d5b5565e53291c8e5ef038 (patch)
treed50e9d8c79ee1a8b1b1a71894b033808a68eab59 /lib/file.c
parente3ee73b70ceaf2663fc2d26a4102e131a7c9618d (diff)
downloadgnurl-4ad8e142da463ab208d5b5565e53291c8e5ef038.tar.gz
gnurl-4ad8e142da463ab208d5b5565e53291c8e5ef038.tar.bz2
gnurl-4ad8e142da463ab208d5b5565e53291c8e5ef038.zip
urldata: clean up the use of the protocol specific structs
1 - always allocate the struct in protocol->setup_connection. Some protocol handlers had to get this function added. 2 - always free at the end of a request. This is also an attempt to keep less memory in the handle after it is completed.
Diffstat (limited to 'lib/file.c')
-rw-r--r--lib/file.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/lib/file.c b/lib/file.c
index 038bf42e1..b77757596 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -186,31 +186,16 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
char *actual_path;
#endif
- /* If there already is a protocol-specific struct allocated for this
- sessionhandle, deal with it */
- Curl_reset_reqproto(conn);
-
real_path = curl_easy_unescape(data, data->state.path, 0, NULL);
if(!real_path)
return CURLE_OUT_OF_MEMORY;
- if(!data->state.proto.file) {
- file = calloc(1, sizeof(struct FILEPROTO));
- if(!file) {
- free(real_path);
- return CURLE_OUT_OF_MEMORY;
- }
- data->state.proto.file = file;
- }
- else {
- /* file is not a protocol that can deal with "persistancy" */
- file = data->state.proto.file;
- Curl_safefree(file->freepath);
- file->path = NULL;
- if(file->fd != -1)
- close(file->fd);
- file->fd = -1;
+ file = calloc(1, sizeof(struct FILEPROTO));
+ if(!file) {
+ free(real_path);
+ return CURLE_OUT_OF_MEMORY;
}
+ data->state.proto.file = file;
#ifdef DOS_FILESYSTEM
/* If the first character is a slash, and there's
@@ -450,7 +435,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
return file_upload(conn);
/* get the fd from the connection phase */
- fd = conn->data->state.proto.file->fd;
+ fd = data->state.proto.file->fd;
/* VMS: This only works reliable for STREAMLF files */
if(-1 != fstat(fd, &statbuf)) {