MCPcopy Create free account
hub / github.com/MariaDB/server / init_tmpdir

Function init_tmpdir

mysys/mf_tempdir.c:25–71  ·  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(key_memory_MY_TMPDIR_full_list, &tmpdir->full_list,
34 sizeof(char*), 1, 5, MYF(0)))
35 goto err;
36 if (!pathlist || !pathlist[0])
37 {
38 /* Get default temporary directory */
39 pathlist=getenv("TMPDIR"); /* Use this if possible */
40#if defined(_WIN32)
41 if (!pathlist)
42 pathlist=getenv("TEMP");
43 if (!pathlist)
44 pathlist=getenv("TMP");
45#endif
46 if (!pathlist || !pathlist[0])
47 pathlist= DEFAULT_TMPDIR;
48 }
49 do
50 {
51 size_t length;
52 end=strcend(pathlist, DELIM);
53 strmake(buff, pathlist, (uint) (end-pathlist));
54 length= cleanup_dirname(buff, buff);
55 if (!(copy= my_strndup(key_memory_MY_TMPDIR_full_list, buff, length, MYF(MY_WME))) ||
56 insert_dynamic(&tmpdir->full_list, (uchar*) &copy))
57 DBUG_RETURN(TRUE);
58 pathlist=end+1;
59 }
60 while (*end);
61 freeze_size(&tmpdir->full_list);
62 tmpdir->list=(char **)tmpdir->full_list.buffer;
63 tmpdir->max=tmpdir->full_list.elements-1;
64 tmpdir->cur=0;
65 DBUG_RETURN(FALSE);
66
67err:
68 delete_dynamic(&tmpdir->full_list); /* Safe to free */
69 mysql_mutex_destroy(&tmpdir->mutex);
70 DBUG_RETURN(TRUE);
71}
72
73
74char *my_tmpdir(MY_TMPDIR *tmpdir)

Callers 6

mainFunction · 0.85
fix_pathsFunction · 0.85
innodb_init_paramFunction · 0.85
get_optionsFunction · 0.85
get_optionsFunction · 0.85
get_optionsFunction · 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