forked from curl/curl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tool: Generate easysrc with last cache linked-list
Using a last cache linked-list improves the performance of easysrc generation. Bug: curl#444 Ref: curl#429
- Loading branch information
1 parent
684bf30
commit 2717cc8
Showing
6 changed files
with
183 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 1998 - 2015, 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 | ||
* are also available at http://curl.haxx.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
***************************************************************************/ | ||
|
||
#include "tool_setup.h" | ||
|
||
#ifndef CURL_DISABLE_LIBCURL_OPTION | ||
|
||
#include "slist_wc.h" | ||
|
||
/* The last #include files should be: */ | ||
#include "curl_memory.h" | ||
#include "memdebug.h" | ||
|
||
/* | ||
* curl_slist_wc_append() appends a string to the linked list. This function | ||
* can be used as an initialization function as well as an append function. | ||
*/ | ||
struct curl_slist_wc *curl_slist_wc_append(struct curl_slist_wc *list, | ||
const char *data) | ||
{ | ||
struct curl_slist *new_item = curl_slist_append(NULL, data); | ||
|
||
if(!new_item) | ||
return NULL; | ||
|
||
if(!list) { | ||
list = malloc(sizeof(struct curl_slist_wc)); | ||
|
||
if(!list) { | ||
free(new_item); | ||
return NULL; | ||
} | ||
|
||
list->first = new_item; | ||
list->last = new_item; | ||
return list; | ||
} | ||
|
||
list->last->next = new_item; | ||
list->last = list->last->next; | ||
return list; | ||
} | ||
|
||
/* be nice and clean up resources */ | ||
void curl_slist_wc_free_all(struct curl_slist_wc *list) | ||
{ | ||
if(!list) | ||
return; | ||
|
||
curl_slist_free_all(list->first); | ||
free(list); | ||
} | ||
|
||
#endif /* CURL_DISABLE_LIBCURL_OPTION */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef HEADER_CURL_SLIST_WC_H | ||
#define HEADER_CURL_SLIST_WC_H | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 1998 - 2015, 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 | ||
* are also available at http://curl.haxx.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
***************************************************************************/ | ||
|
||
#include "tool_setup.h" | ||
#ifndef CURL_DISABLE_LIBCURL_OPTION | ||
|
||
/* linked-list structure with last node cache for easysrc */ | ||
struct curl_slist_wc { | ||
struct curl_slist *first; | ||
struct curl_slist *last; | ||
}; | ||
|
||
/* | ||
* NAME curl_slist_wc_append() | ||
* | ||
* DESCRIPTION | ||
* | ||
* Appends a string to a linked list. If no list exists, it will be created | ||
* first. Returns the new list, after appending. | ||
*/ | ||
struct curl_slist_wc *curl_slist_wc_append(struct curl_slist_wc *, | ||
const char *); | ||
|
||
/* | ||
* NAME curl_slist_free_all() | ||
* | ||
* DESCRIPTION | ||
* | ||
* free a previously built curl_slist_wc. | ||
*/ | ||
void curl_slist_wc_free_all(struct curl_slist_wc *); | ||
|
||
#endif /* CURL_DISABLE_LIBCURL_OPTION */ | ||
|
||
#endif /* HEADER_CURL_SLIST_WC_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters