diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2004-12-26 12:45:22 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2004-12-26 12:45:22 +0100 |
commit | 286af66cfb787b76ee7289c920a75a3dd21ce795 (patch) | |
tree | f3c726662154652682da356ef5fa66a91a0a4675 /videodir.c | |
parent | f97b1069c6bdf519fd32280b35ed66abe6c02bde (diff) | |
download | vdr-286af66cfb787b76ee7289c920a75a3dd21ce795.tar.gz vdr-286af66cfb787b76ee7289c920a75a3dd21ce795.tar.bz2 |
Made several functions threadsafe (cont'd)
Diffstat (limited to 'videodir.c')
-rw-r--r-- | videodir.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: videodir.c 1.10 2003/08/02 13:43:28 kls Exp $ + * $Id: videodir.c 1.11 2004/12/26 11:52:12 kls Exp $ */ #include "videodir.h" @@ -197,27 +197,23 @@ int VideoDiskSpace(int *FreeMB, int *UsedMB) return (free + used) ? used * 100 / (free + used) : 0; } -const char *PrefixVideoFileName(const char *FileName, char Prefix) +cString PrefixVideoFileName(const char *FileName, char Prefix) { - static char *PrefixedName = NULL; - - if (!PrefixedName || strlen(PrefixedName) <= strlen(FileName)) - PrefixedName = (char *)realloc(PrefixedName, strlen(FileName) + 2); - if (PrefixedName) { - const char *p = FileName + strlen(FileName); // p points at the terminating 0 - int n = 2; - while (p-- > FileName && n > 0) { - if (*p == '/') { - if (--n == 0) { - int l = p - FileName + 1; - strncpy(PrefixedName, FileName, l); - PrefixedName[l] = Prefix; - strcpy(PrefixedName + l + 1, p + 1); - return PrefixedName; - } + char PrefixedName[strlen(FileName) + 2]; + + const char *p = FileName + strlen(FileName); // p points at the terminating 0 + int n = 2; + while (p-- > FileName && n > 0) { + if (*p == '/') { + if (--n == 0) { + int l = p - FileName + 1; + strncpy(PrefixedName, FileName, l); + PrefixedName[l] = Prefix; + strcpy(PrefixedName + l + 1, p + 1); + return PrefixedName; } } - } + } return NULL; } |