From 3215261518f1569e2e7f402dc189def95e551b26 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 12 Feb 2009 18:52:12 +0000 Subject: [PATCH] -move FCB_TAG to header -use ExAllocatePoolWithTag / ExFreePoolWithTag -free the NameListResource when destroying an FCB -get rid of CdfsWriteNumberInShortName svn path=/trunk/; revision=39571 --- reactos/drivers/filesystems/cdfs/cdfs.h | 1 + reactos/drivers/filesystems/cdfs/fcb.c | 7 +++--- reactos/drivers/filesystems/cdfs/misc.c | 31 +++---------------------- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/reactos/drivers/filesystems/cdfs/cdfs.h b/reactos/drivers/filesystems/cdfs/cdfs.h index 744fa73607d..63db19b3197 100644 --- a/reactos/drivers/filesystems/cdfs/cdfs.h +++ b/reactos/drivers/filesystems/cdfs/cdfs.h @@ -232,6 +232,7 @@ typedef struct _CCB #endif #define TAG_CCB TAG('I', 'C', 'C', 'B') +#define TAG_FCB TAG('I', 'F', 'C', 'B') typedef struct { diff --git a/reactos/drivers/filesystems/cdfs/fcb.c b/reactos/drivers/filesystems/cdfs/fcb.c index 0b4de6ea625..afc2beac4f4 100644 --- a/reactos/drivers/filesystems/cdfs/fcb.c +++ b/reactos/drivers/filesystems/cdfs/fcb.c @@ -35,8 +35,6 @@ /* FUNCTIONS ****************************************************************/ -#define TAG_FCB TAG('I', 'F', 'C', 'B') - #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S)) @@ -114,10 +112,11 @@ CdfsDestroyFCB(PFCB Fcb) { Entry = Fcb->ShortNameList.Flink; RemoveEntryList(Entry); - ExFreePool(Entry); + ExFreePoolWithTag(Entry, TAG_FCB); } - ExFreePool(Fcb); + ExDeleteResourceLite(&Fcb->NameListResource); + ExFreePoolWithTag(Fcb, TAG_FCB); } diff --git a/reactos/drivers/filesystems/cdfs/misc.c b/reactos/drivers/filesystems/cdfs/misc.c index 2f8c471a637..72068ad99a5 100644 --- a/reactos/drivers/filesystems/cdfs/misc.c +++ b/reactos/drivers/filesystems/cdfs/misc.c @@ -95,21 +95,6 @@ CdfsFileFlagsToAttributes(PFCB Fcb, ((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0); } -/* Writes a number into a string, ending at the target position. */ -static PWCHAR -CdfsWriteNumberInShortName -(PWCHAR EndOfNumberTarget, - ULONG Number) -{ - while (Number) - { - *EndOfNumberTarget = '0' + (Number % 10); - EndOfNumberTarget--; - Number /= 10; - } - return EndOfNumberTarget; -} - VOID CdfsShortNameCacheGet (PFCB DirectoryFcb, @@ -118,11 +103,9 @@ CdfsShortNameCacheGet PUNICODE_STRING ShortName) { BOOLEAN HasSpaces; - PWCHAR LastDot, Scan; - ULONG Number = 1; PLIST_ENTRY Entry; PCDFS_SHORT_NAME ShortNameEntry; - GENERATE_NAME_CONTEXT Context = { }; + GENERATE_NAME_CONTEXT Context = { 0 }; DPRINT("CdfsShortNameCacheGet(%I64u,%wZ)\n", StreamOffset->QuadPart, LongName); @@ -165,13 +148,6 @@ CdfsShortNameCacheGet DPRINT("Initial Guess %wZ\n", ShortName); - /* Find the part that'll be numberified */ - LastDot = &ShortName->Buffer[(ShortName->Length / sizeof(WCHAR)) - 1]; - for (Scan = ShortName->Buffer; - Scan - ShortName->Buffer < ShortName->Length; - Scan++) - if (*Scan == '.') LastDot = Scan - 1; - /* Make it unique by scanning the cache and bumping */ /* Note that incrementing the ambiguous name is enough, since we add new * entries at the tail. We'll scan over all collisions. */ @@ -186,14 +162,13 @@ CdfsShortNameCacheGet &ShortNameEntry->Name, TRUE) == 0) /* Match */ { - Scan = CdfsWriteNumberInShortName(LastDot, ++Number); - *Scan = '~'; + RtlGenerate8dot3Name(LongName, FALSE, &Context, ShortName); DPRINT("Collide; try %wZ\n", ShortName); } } /* We've scanned over all entries and now have a unique one. Cache it. */ - ShortNameEntry = ExAllocatePool(PagedPool, sizeof(CDFS_SHORT_NAME)); + ShortNameEntry = ExAllocatePoolWithTag(PagedPool, sizeof(CDFS_SHORT_NAME), TAG_FCB); if (!ShortNameEntry) { /* We couldn't cache it, but we can return it. We run the risk of