00001 /*************************************************************************** 00002 * _ _ ____ _ 00003 * Project ___| | | | _ \| | 00004 * / __| | | | |_) | | 00005 * | (__| |_| | _ <| |___ 00006 * \___|\___/|_| \_\_____| 00007 * 00008 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. 00009 * 00010 * This software is licensed as described in the file COPYING, which 00011 * you should have received as part of this distribution. The terms 00012 * are also available at https://curl.haxx.se/docs/copyright.html. 00013 * 00014 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 00015 * copies of the Software, and permit persons to whom the Software is 00016 * furnished to do so, under the terms of the COPYING file. 00017 * 00018 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 00019 * KIND, either express or implied. 00020 * 00021 ***************************************************************************/ 00022 00023 #include "curl_setup.h" 00024 00025 #include "wildcard.h" 00026 #include "llist.h" 00027 #include "fileinfo.h" 00028 /* The last 3 #include files should be in this order */ 00029 #include "curl_printf.h" 00030 #include "curl_memory.h" 00031 #include "memdebug.h" 00032 00033 CURLcode Curl_wildcard_init(struct WildcardData *wc) 00034 { 00035 DEBUGASSERT(wc->filelist == NULL); 00036 /* now allocate only wc->filelist, everything else 00037 will be allocated if it is needed. */ 00038 wc->filelist = Curl_llist_alloc(Curl_fileinfo_dtor); 00039 if(!wc->filelist) {; 00040 return CURLE_OUT_OF_MEMORY; 00041 } 00042 return CURLE_OK; 00043 } 00044 00045 void Curl_wildcard_dtor(struct WildcardData *wc) 00046 { 00047 if(!wc) 00048 return; 00049 00050 if(wc->tmp_dtor) { 00051 wc->tmp_dtor(wc->tmp); 00052 wc->tmp_dtor = ZERO_NULL; 00053 wc->tmp = NULL; 00054 } 00055 DEBUGASSERT(wc->tmp == NULL); 00056 00057 if(wc->filelist) { 00058 Curl_llist_destroy(wc->filelist, NULL); 00059 wc->filelist = NULL; 00060 } 00061 00062 free(wc->path); 00063 wc->path = NULL; 00064 free(wc->pattern); 00065 wc->pattern = NULL; 00066 00067 wc->customptr = NULL; 00068 wc->state = CURLWC_INIT; 00069 }