X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cde%2Flib%2FDtSvc%2FDtUtil1%2FMMDb.c;h=8425643851551ef9d2768bf269d49a021e7690fd;hb=dbce2e4337f1a61563436f531741bf0145e6ad8b;hp=7891340e834d738557ac928e57727e8c4796ecb0;hpb=04b366b09cb7b84cc92f9b4e25342fc42ef0f086;p=oweals%2Fcde.git diff --git a/cde/lib/DtSvc/DtUtil1/MMDb.c b/cde/lib/DtSvc/DtUtil1/MMDb.c index 7891340e..84256438 100644 --- a/cde/lib/DtSvc/DtUtil1/MMDb.c +++ b/cde/lib/DtSvc/DtUtil1/MMDb.c @@ -16,7 +16,7 @@ * details. * * You should have received a copy of the GNU Lesser General Public - * License along with these librararies and programs; if not, write + * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ @@ -32,12 +32,12 @@ #include #include -#include #include #include #include #include +#include #ifdef NLS16 #include @@ -77,6 +77,10 @@ static DtShmProtoIntList int_handle = 0; #define QtB(a) _DtShmProtoAddStrtab(shm_handle, XrmQuarkToString(a), &isnew) +/* DtsMM.c */ +extern int _DtDtsMMPathHash(DtDirPaths *dirs); + + int _MMWriteDb(DtDirPaths *dirs, int num_db, DtDtsDbDatabase **db_list, const char *CacheFile) @@ -176,7 +180,7 @@ build_file_list(DtShmProtoIntList int_handle, DtDirPaths *dirs, mtime_list[count-1] = buf.st_mtime; boson_list[count-1] = _DtShmProtoAddStrtab(shm_handle, pathname, &isnew); - if (pathname) free(pathname); + free(pathname); continue; } } @@ -188,8 +192,8 @@ build_file_list(DtShmProtoIntList int_handle, DtDirPaths *dirs, data = _DtShmProtoAddIntLst(int_handle, count*sizeof(time_t)/sizeof(int), &header->mtimes_offset); memcpy(data, mtime_list, count*sizeof(time_t)); header->files_count = count; - if(boson_list)free(boson_list); - if(mtime_list)free(mtime_list); + free(boson_list); + free(mtime_list); return; } @@ -662,9 +666,9 @@ printf("head->buffer_start_index = %d\n", head->buffer_start_index); &head->name_list_offset); _DtShmProtoCopyInttab(indexList, space); _DtShmProtoDestroyInttab(indexList); - if(name_index)free(name_index); - if(list_of_recs)free(list_of_recs); - if(other)free(other); + free(name_index); + free(list_of_recs); + free(other); return(index); } @@ -674,11 +678,6 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile) int fd; mode_t cmask = umask((mode_t)077); char *tmpfile; - /* tempnam(3) is affected by the TMPDIR environment variable. */ - /* This creates problems for rename() is "tmpfile" and "cacheFile" */ - /* are on different file systems. Use tmpnam(3) to create the */ - /* unique file name instead. */ - char tmpnam_buf[L_tmpnam + 1]; if ((tmpfile = malloc(sizeof(_DTDTSMMTEMPDIR) + sizeof(_DTDTSMMTEMPFILE) + 7)) == NULL) { @@ -689,16 +688,6 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile) sprintf(tmpfile, "%s/%sXXXXXX", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE); fd = mkstemp(tmpfile); - /* - tmpfile = (char *)malloc(sizeof(_DTDTSMMTEMPDIR) + - sizeof(_DTDTSMMTEMPFILE) + L_tmpnam + 3); - - tmpnam(tmpnam_buf); - sprintf(tmpfile, "%s/%s%s", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE, - basename(tmpnam_buf)); - - fd = open(tmpfile, O_RDWR|O_CREAT, 0600); - */ umask(cmask); if(fd == -1) @@ -706,6 +695,7 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile) _DtSimpleError( DtProgName, DtError, NULL, (char*) tmpfile, NULL); + free(tmpfile); return(0); } @@ -738,7 +728,7 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile) } -_DtActionCompareRecordBoson( +intptr_t _DtActionCompareRecordBoson( DtDtsMMRecord *record1, DtDtsMMRecord *record2 ) { @@ -747,5 +737,5 @@ _DtActionCompareRecordBoson( if (results) return(results); - return((int)record1 - (int)record2); + return((intptr_t)record1 - (intptr_t)record2); }