diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2015-03-11 17:41:01 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2015-03-16 12:13:56 +0100 |
commit | 29c655c0a6affc0359e499162e8308663eb4d04f (patch) | |
tree | ed6b1fc761dee6623ec1b312cc53dc3b661c1550 /docs | |
parent | 059b3a5770075315dbc843b9285a1cdec82c12d5 (diff) |
Bug #149: Deletion of unnecessary checks before calls of the function "free"
The function "free" is documented in the way that no action shall occur for
a passed null pointer. It is therefore not needed that a function caller
repeats a corresponding check.
http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first
This issue was fixed by using the software Coccinelle 1.0.0-rc24.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/examples/fopen.c | 12 | ||||
-rw-r--r-- | docs/examples/getinmemory.c | 3 | ||||
-rw-r--r-- | docs/examples/postinmemory.c | 3 |
3 files changed, 5 insertions, 13 deletions
diff --git a/docs/examples/fopen.c b/docs/examples/fopen.c index 3d2a81773..4089bb433 100644 --- a/docs/examples/fopen.c +++ b/docs/examples/fopen.c @@ -210,9 +210,7 @@ static int use_buffer(URL_FILE *file,int want) /* sort out buffer */ if((file->buffer_pos - want) <=0) { /* ditch buffer - write will recreate */ - if(file->buffer) - free(file->buffer); - + free(file->buffer); file->buffer=NULL; file->buffer_pos=0; file->buffer_len=0; @@ -302,9 +300,7 @@ int url_fclose(URL_FILE *file) break; } - if(file->buffer) - free(file->buffer);/* free any allocated buffer space */ - + free(file->buffer);/* free any allocated buffer space */ free(file); return ret; @@ -435,9 +431,7 @@ void url_rewind(URL_FILE *file) curl_multi_add_handle(multi_handle, file->handle.curl); /* ditch buffer - write will recreate - resets stream pos*/ - if(file->buffer) - free(file->buffer); - + free(file->buffer); file->buffer=NULL; file->buffer_pos=0; file->buffer_len=0; diff --git a/docs/examples/getinmemory.c b/docs/examples/getinmemory.c index 1608ec551..a1c21404d 100644 --- a/docs/examples/getinmemory.c +++ b/docs/examples/getinmemory.c @@ -106,8 +106,7 @@ int main(void) /* cleanup curl stuff */ curl_easy_cleanup(curl_handle); - if(chunk.memory) - free(chunk.memory); + free(chunk.memory); /* we're done with libcurl, so clean it up */ curl_global_cleanup(); diff --git a/docs/examples/postinmemory.c b/docs/examples/postinmemory.c index cd2bd13fb..3afac4b2f 100644 --- a/docs/examples/postinmemory.c +++ b/docs/examples/postinmemory.c @@ -101,8 +101,7 @@ int main(void) /* always cleanup */ curl_easy_cleanup(curl); - if(chunk.memory) - free(chunk.memory); + free(chunk.memory); /* we're done with libcurl, so clean it up */ curl_global_cleanup(); |