MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / init_tmpdir

Function init_tmpdir

mysys/mf_tempdir.c:25–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#endif
24
25my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
26{
27 char *end, *copy;
28 char buff[FN_REFLEN];
29 DBUG_ENTER("init_tmpdir");
30 DBUG_PRINT("enter", ("pathlist: %s", pathlist ? pathlist : "NULL"));
31
32 mysql_mutex_init(key_TMPDIR_mutex, &tmpdir->mutex, MY_MUTEX_INIT_FAST);
33 if (my_init_dynamic_array(&tmpdir->full_list, sizeof(char*), 1, 5))
34 goto err;
35 if (!pathlist || !pathlist[0])
36 {
37 /* Get default temporary directory */
38 pathlist=getenv("TMPDIR"); /* Use this if possible */
39#if defined(__WIN__)
40 if (!pathlist)
41 pathlist=getenv("TEMP");
42 if (!pathlist)
43 pathlist=getenv("TMP");
44#endif
45 if (!pathlist || !pathlist[0])
46 pathlist= DEFAULT_TMPDIR;
47 }
48 do
49 {
50 size_t length;
51 end=strcend(pathlist, DELIM);
52 strmake(buff, pathlist, (uint) (end-pathlist));
53 length= cleanup_dirname(buff, buff);
54 if (!(copy= my_strndup(buff, length, MYF(MY_WME))) ||
55 insert_dynamic(&tmpdir->full_list, &copy))
56 DBUG_RETURN(TRUE);
57 pathlist=end+1;
58 }
59 while (*end);
60 freeze_size(&tmpdir->full_list);
61 tmpdir->list=(char **)tmpdir->full_list.buffer;
62 tmpdir->max=tmpdir->full_list.elements-1;
63 tmpdir->cur=0;
64 DBUG_RETURN(FALSE);
65
66err:
67 delete_dynamic(&tmpdir->full_list); /* Safe to free */
68 mysql_mutex_destroy(&tmpdir->mutex);
69 DBUG_RETURN(TRUE);
70}
71
72
73char *my_tmpdir(MY_TMPDIR *tmpdir)

Callers 1

fix_pathsFunction · 0.85

Calls 7

strcendFunction · 0.85
strmakeFunction · 0.85
cleanup_dirnameFunction · 0.85
my_strndupFunction · 0.85
insert_dynamicFunction · 0.85
freeze_sizeFunction · 0.85
delete_dynamicFunction · 0.85

Tested by

no test coverage detected