~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_tempdir.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 19:43:08 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717194308-l9i4ti57gikm2qbv
Phase 1 removal of DBUG in mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "mysys_priv.h"
17
 
#include <mystrings/m_string.h>
 
17
#include <m_string.h>
18
18
 
19
19
#define DELIM ':'
20
20
 
21
21
bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
22
22
{
23
 
  const char *end;
24
 
  char *copy;
 
23
  char *end, *copy;
25
24
  char buff[FN_REFLEN];
26
25
 
27
26
  pthread_mutex_init(&tmpdir->mutex, MY_MUTEX_INIT_FAST);
34
33
    if (!pathlist || !pathlist[0])
35
34
      pathlist=(char*) P_tmpdir;
36
35
  }
37
 
  do {
38
 
    uint32_t length;
39
 
    end= strrchr(pathlist, DELIM);
40
 
    if (end == NULL)
41
 
      end= pathlist+strlen(pathlist);
 
36
  do
 
37
  {
 
38
    uint length;
 
39
    end=strcend(pathlist, DELIM);
42
40
    strmake(buff, pathlist, (uint) (end-pathlist));
43
41
    length= cleanup_dirname(buff, buff);
44
42
    if (!(copy= my_strndup(buff, length, MYF(MY_WME))) ||
45
 
        insert_dynamic(&tmpdir->full_list, (unsigned char*) &copy))
 
43
        insert_dynamic(&tmpdir->full_list, (uchar*) &copy))
46
44
      return(true);
47
45
    pathlist=end+1;
48
 
  } while (*end != '\0');
 
46
  }
 
47
  while (*end);
49
48
  freeze_size(&tmpdir->full_list);
50
49
  tmpdir->list=(char **)tmpdir->full_list.buffer;
51
50
  tmpdir->max=tmpdir->full_list.elements-1;
73
72
 
74
73
void free_tmpdir(MY_TMPDIR *tmpdir)
75
74
{
76
 
  uint32_t i;
 
75
  uint i;
77
76
  for (i=0; i<=tmpdir->max; i++)
78
 
    free(tmpdir->list[i]);
 
77
    my_free(tmpdir->list[i], MYF(0));
79
78
  delete_dynamic(&tmpdir->full_list);
80
79
  pthread_mutex_destroy(&tmpdir->mutex);
81
80
}