Changeset 2967 in kBuild
- Timestamp:
- Sep 26, 2016 6:14:13 PM (8 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/msc_buffered_printf.c
r2910 r2967 47 47 #pragma warning(disable: 4273) /* inconsistent dll linkage*/ 48 48 49 #ifndef KWORKER 50 # define DLL_IMPORT __declspec(dllexport) 51 #else 52 # define DLL_IMPORT 53 #endif 54 49 55 extern size_t maybe_con_fwrite(void const *pvBuf, size_t cbUnit, size_t cUnits, FILE *pFile); 50 56 … … 57 63 * @param ... Format arguments. 58 64 */ 59 __declspec(dllexport) 65 DLL_IMPORT 60 66 int __cdecl printf(const char *pszFormat, ...) 61 67 { … … 76 82 * @param va Format arguments. 77 83 */ 78 __declspec(dllexport) 84 DLL_IMPORT 79 85 int __cdecl vprintf(const char *pszFormat, va_list va) 80 86 { … … 114 120 * @param va Format arguments. 115 121 */ 116 __declspec(dllexport) 122 DLL_IMPORT 117 123 int __cdecl fprintf(FILE *pFile, const char *pszFormat, ...) 118 124 { … … 160 166 * @param pszString The string to write. (newline is appended) 161 167 */ 162 __declspec(dllexport) 168 DLL_IMPORT 163 169 int __cdecl puts(const char *pszString) 164 170 { … … 235 241 * @param pFile The output file. 236 242 */ 237 __declspec(dllexport) 243 DLL_IMPORT 238 244 int __cdecl fputs(const char *pszString, FILE *pFile) 239 245 { -
trunk/src/lib/nt/kFsCache.c
r2948 r2967 597 597 pObj->uNameHash = 0; 598 598 pObj->pNextNameHash = NULL; 599 pObj->pNameAlloc = NULL; 599 600 pObj->pUserDataHead = NULL; 600 601 … … 804 805 } 805 806 807 808 /** 809 * Does the growing of names. 810 * 811 * @returns pCur 812 * @param pCache The cache. 813 * @param pCur The object. 814 * @param pchName The name (not necessarily terminated). 815 * @param cchName Name length. 816 * @param pwcName The UTF-16 name (not necessarily terminated). 817 * @param cwcName The length of the UTF-16 name in wchar_t's. 818 * @param pchShortName The short name. 819 * @param cchShortName The length of the short name. This is 0 if no short 820 * name. 821 * @param pwcShortName The short UTF-16 name. 822 * @param cwcShortName The length of the short UTF-16 name. This is 0 if 823 * no short name. 824 */ 825 static PKFSOBJ kFsCacheRefreshGrowNames(PKFSCACHE pCache, PKFSOBJ pCur, 826 const char *pchName, KU32 cchName, 827 wchar_t const *pwcName, KU32 cwcName 828 #ifdef KFSCACHE_CFG_SHORT_NAMES 829 , const char *pchShortName, KU32 cchShortName, 830 wchar_t const *pwcShortName, KU32 cwcShortName 831 #endif 832 ) 833 { 834 PKFSOBJNAMEALLOC pNameAlloc; 835 char *pch; 836 KU32 cbNeeded; 837 838 pCache->cNameGrowths++; 839 840 /* 841 * Figure out our requirements. 842 */ 843 cbNeeded = sizeof(KU32) + cchName + 1; 844 #ifdef KFSCACHE_CFG_UTF16 845 cbNeeded += (cwcName + 1) * sizeof(wchar_t); 846 #endif 847 #ifdef KFSCACHE_CFG_SHORT_NAMES 848 cbNeeded += cchShortName + !!cchShortName; 849 # ifdef KFSCACHE_CFG_UTF16 850 cbNeeded += (cwcShortName + !!cwcShortName) * sizeof(wchar_t); 851 # endif 852 #endif 853 cbNeeded = K_ALIGN_Z(cbNeeded, 8); /* Memory will likely be 8 or 16 byte aligned, so we might just claim it. */ 854 855 /* 856 * Allocate memory. 857 */ 858 pNameAlloc = pCur->pNameAlloc; 859 if (!pNameAlloc) 860 { 861 pNameAlloc = (PKFSOBJNAMEALLOC)kHlpAlloc(cbNeeded); 862 if (!pNameAlloc) 863 return pCur; 864 pCache->cbObjects += cbNeeded; 865 pCur->pNameAlloc = pNameAlloc; 866 pNameAlloc->cb = cbNeeded; 867 } 868 else if (pNameAlloc->cb < cbNeeded) 869 { 870 pNameAlloc = (PKFSOBJNAMEALLOC)kHlpRealloc(pNameAlloc, cbNeeded); 871 if (!pNameAlloc) 872 return pCur; 873 pCache->cbObjects += cbNeeded - pNameAlloc->cb; 874 pCur->pNameAlloc = pNameAlloc; 875 pNameAlloc->cb = cbNeeded; 876 } 877 878 /* 879 * Copy out the new names, starting with the wide char ones to avoid misaligning them. 880 */ 881 pch = &pNameAlloc->abSpace[0]; 882 883 #ifdef KFSCACHE_CFG_UTF16 884 pCur->pwszName = (wchar_t *)pch; 885 pCur->cwcName = cwcName; 886 pch = kHlpMemPCopy(pch, pwcName, cwcName * sizeof(wchar_t)); 887 *pch++ = '\0'; 888 *pch++ = '\0'; 889 890 # ifdef KFSCACHE_CFG_SHORT_NAMES 891 if (cwcShortName == 0) 892 { 893 pCur->pwszShortName = pCur->pwszName; 894 pCur->cwcShortName = pCur->cwcName; 895 } 896 else 897 { 898 pCur->pwszShortName = (wchar_t *)pch; 899 pCur->cwcShortName = cwcShortName; 900 pch = kHlpMemPCopy(pch, pwcShortName, cwcShortName * sizeof(wchar_t)); 901 *pch++ = '\0'; 902 *pch++ = '\0'; 903 } 904 # endif 905 #endif 906 907 pCur->pszName = pch; 908 pCur->cchName = cchName; 909 pch = kHlpMemPCopy(pch, pchName, cchShortName); 910 *pch++ = '\0'; 911 912 #ifdef KFSCACHE_CFG_SHORT_NAMES 913 if (cchShortName == 0) 914 { 915 pCur->pszShortName = pCur->pszName; 916 pCur->cchShortName = pCur->cchName; 917 } 918 else 919 { 920 pCur->pszShortName = pch; 921 pCur->cchShortName = cchShortName; 922 pch = kHlpMemPCopy(pch, pchShortName, cchShortName); 923 *pch++ = '\0'; 924 } 925 #endif 926 927 return pCur; 928 } 929 930 806 931 /** 807 932 * Worker for kFsCacheDirFindOldChild that refreshes the file ID value on an 808 933 * object found by name. 809 934 * 810 * @returns Pointer to the existing object if found, NULL if not.935 * @returns pCur. 811 936 * @param pDirRePop Repopulation data. 812 937 * @param pCur The object to check the names of. … … 828 953 * has been found the file ID. 829 954 * 830 * @returns Pointer to the existing object if found, NULL if not.955 * @returns pCur. 831 956 * @param pDirRePop Repopulation data. 832 957 * @param pCur The object to check the names of. … … 842 967 ) 843 968 { 969 char szName[KFSCACHE_CFG_MAX_ANSI_NAME]; 970 int cchName; 971 972 pDirRePop->pCache->cNameChanges++; 973 844 974 /* 845 975 * Convert the names to ANSI first, that way we know all the lengths. 846 976 */ 847 char szName[KFSCACHE_CFG_MAX_ANSI_NAME]; 848 int cchName = WideCharToMultiByte(CP_ACP, 0, pwcName, cwcName, szName, sizeof(szName) - 1, NULL, NULL); 977 cchName = WideCharToMultiByte(CP_ACP, 0, pwcName, cwcName, szName, sizeof(szName) - 1, NULL, NULL); 849 978 if (cchName >= 0) 850 979 { … … 916 1045 } 917 1046 } 918 } 919 } 920 921 922 fprintf(stderr, 923 "kFsCacheDirRefreshOldChildName - not implemented!\n" 924 " Old name: %#x '%ls'\n" 925 " New name: %#x '%*.*ls'\n" 926 " Old short: %#x '%ls'\n" 927 " New short: %#x '%*.*ls'\n", 928 pCur->cwcName, pCur->pwszName, 929 cwcName, cwcName, cwcName, pwcName, 930 pCur->cwcShortName, pCur->pwszShortName, 931 cwcShortName, cwcShortName, cwcShortName, pwcShortName); 932 __debugbreak(); 933 /** @todo implement this. It's not entirely straight forward, especially if 934 * the name increases! Also, it's something that may happend during 935 * individual object refresh and we might want to share code... */ 936 1047 1048 return kFsCacheRefreshGrowNames(pDirRePop->pCache, pCur, szName, cchName, pwcName, cwcName, 1049 #ifdef KFSCACHE_CFG_SHORT_NAMES 1050 szShortName, cchShortName, pwcShortName, cwcShortName 1051 #endif 1052 ); 1053 } 1054 } 1055 1056 fprintf(stderr, "kFsCacheDirRefreshOldChildName: WideCharToMultiByte error\n"); 937 1057 return pCur; 938 1058 } … … 941 1061 /** 942 1062 * Worker for kFsCacheDirFindOldChild that checks the names after an old object 943 * has been found the file ID.944 * 945 * @returns Pointer to the existing object if found, NULL if not.1063 * has been found by the file ID. 1064 * 1065 * @returns pCur. 946 1066 * @param pDirRePop Repopulation data. 947 1067 * @param pCur The object to check the names of. … … 3767 3887 pCache->cObjects--; 3768 3888 3889 if (pObj->pNameAlloc) 3890 { 3891 pCache->cbObjects -= pObj->pNameAlloc->cb; 3892 kHlpFree(pObj->pNameAlloc); 3893 } 3894 3769 3895 kHlpFree(pObj); 3770 3896 return 0; … … 4437 4563 pCache->cChildHashEntriesTotal = pCache->RootDir.fHashTabMask + 1; 4438 4564 pCache->cChildHashCollisions = 0; 4565 pCache->cNameChanges = 0; 4566 pCache->cNameGrowths = 0; 4439 4567 pCache->cAnsiPaths = 0; 4440 4568 pCache->cAnsiPathCollisions = 0; -
trunk/src/lib/nt/kFsCache.h
r2945 r2967 130 130 131 131 /** 132 * Storage for name strings for the unlikely event that they should grow in 133 * length after the KFSOBJ was created. 134 */ 135 typedef struct KFSOBJNAMEALLOC 136 { 137 /** Size of the allocation. */ 138 KU32 cb; 139 /** The space for names. */ 140 char abSpace[1]; 141 } KFSOBJNAMEALLOC; 142 /** Name growth allocation. */ 143 typedef KFSOBJNAMEALLOC *PKFSOBJNAMEALLOC; 144 145 146 /** 132 147 * Base cache node. 133 148 */ … … 201 216 # endif 202 217 #endif 218 219 /** Allocation for handling name length increases. */ 220 PKFSOBJNAMEALLOC pNameAlloc; 203 221 204 222 /** Pointer to the first user data item */ … … 411 429 /** Number of children inserted into the hash tables. */ 412 430 KSIZE cChildHashed; 413 /** Number of collisions in the child hash tables */431 /** Number of collisions in the child hash tables. */ 414 432 KSIZE cChildHashCollisions; 433 /** Number times a object name changed. */ 434 KSIZE cNameChanges; 435 /** Number times a object name grew and needed KFSOBJNAMEALLOC. 436 * (Subset of cNameChanges) */ 437 KSIZE cNameGrowths; 415 438 416 439 /** The root directory. */
Note:
See TracChangeset
for help on using the changeset viewer.