Changeset 907 for trunk/dll/makelist.c
- Timestamp:
- Jan 6, 2008, 8:26:17 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/makelist.c
r841 r907 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2003, 200 7Steven H.Levine9 Copyright (c) 2003, 2008 Steven H.Levine 10 10 11 11 12 Feb 03 SHL AddToFileList: standardize EA math … … 17 17 ***********************************************************************/ 18 18 19 #include <stdlib.h> 20 #include <string.h> 21 19 22 #define INCL_DOS 20 23 #define INCL_WIN 21 24 #define INCL_LONGLONG 22 #include <os2.h> 23 24 #include <stdio.h> 25 #include <stdlib.h> 26 #include <string.h> 27 #include <ctype.h> 28 29 #include "fm3dll.h" 25 30 26 #include "fm3str.h" 27 #include "makelist.h" 28 #include "errutil.h" // Dos_Error... 29 #include "strutil.h" // GetPString 30 #include "dircnrs.h" 31 #include "fm3dll.h" // 05 Jan 08 SHL fixme to be gone 31 32 32 33 static PSZ pszSrcFile = __FILE__; 33 34 34 VOID SortList(LISTINFO * 35 VOID SortList(LISTINFO *li) 35 36 { 36 37 /* bubble-sort entries by size, descending */ 37 38 38 INT x;39 UINT x; 39 40 CHAR *s; 40 41 ULONG l; … … 64 65 } 65 66 66 VOID FreeListInfo(LISTINFO * 67 VOID FreeListInfo(LISTINFO *li) 67 68 { 68 69 if (li) { … … 77 78 } 78 79 79 VOID FreeList(CHAR ** 80 { 81 registerINT x;80 VOID FreeList(CHAR **list) 81 { 82 UINT x; 82 83 83 84 if (list) { … … 96 97 } 97 98 98 INT AddToFileList(CHAR * string, FILEFINDBUF4L * ffb4, FILELIST ***list,99 INT * numfiles, INT *numalloced)99 INT AddToFileList(CHAR *string, FILEFINDBUF4L *ffb4, FILELIST ***list, 100 UINT *pnumfiles, UINT *pnumalloced) 100 101 { 101 102 FILELIST *pfl; … … 103 104 if (string && ffb4) { 104 105 // Ensure room for NULL entry 105 if (((* numfiles) + 3) > *numalloced) {106 if (((*pnumfiles) + 3) > *pnumalloced) { 106 107 FILELIST **pflArray; 107 108 108 109 // Use plain realloc for speed 109 110 // 06 Aug 07 SHL fixme to know why + 6 110 pflArray = realloc(*list, (* numalloced + 6) * sizeof(FILELIST *));111 pflArray = realloc(*list, (*pnumalloced + 6) * sizeof(FILELIST *)); 111 112 if (!pflArray) { 112 113 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY)); 113 114 return 1; 114 115 } 115 (* numalloced) += 6;116 (*pnumalloced) += 6; 116 117 *list = pflArray; 117 118 } … … 132 133 pfl->easize = CBLIST_TO_EASIZE(ffb4->cbList); 133 134 strcpy(pfl->fname, string); 134 (*list)[* numfiles] = pfl;135 (* numfiles)++;135 (*list)[*pnumfiles] = pfl; 136 (*pnumfiles)++; 136 137 // Ensure list always ends with two NULL entries 137 138 // 06 Aug 07 SHL fixme to know why 138 (*list)[* numfiles] = NULL;139 (*list)[(* numfiles) + 1] = NULL;139 (*list)[*pnumfiles] = NULL; 140 (*list)[(*pnumfiles) + 1] = NULL; 140 141 #ifdef __DEBUG_ALLOC__ 141 142 _heap_check(); … … 151 152 */ 152 153 153 INT AddToList(CHAR * string, CHAR *** list, INT * numfiles, INT *numalloced)154 INT AddToList(CHAR *string, CHAR ***list, UINT *pnumfiles, UINT *pnumalloced) 154 155 { 155 156 CHAR **ppsz; … … 157 158 158 159 if (string) { 159 if (((* numfiles) + 3) > *numalloced) {160 if (((*pnumfiles) + 3) > *pnumalloced) { 160 161 // Use plain realloc for speed 161 ppsz = realloc(*list, (* numalloced + 6) * sizeof(CHAR *));162 ppsz = realloc(*list, (*pnumalloced + 6) * sizeof(CHAR *)); 162 163 if (!ppsz) { 163 164 Runtime_Error(pszSrcFile, __LINE__, "realloc"); 164 165 return 1; 165 166 } 166 (* numalloced) += 6;167 (*pnumalloced) += 6; 167 168 *list = ppsz; 168 169 } … … 173 174 return 2; 174 175 } 175 (*list)[* numfiles] = psz;176 strcpy((*list)[* numfiles], string); // Add entry177 (* numfiles)++;178 (*list)[* numfiles] = NULL; // Add end marker179 (*list)[(* numfiles) + 1] = NULL; // Add 2nd end marker - fixme to know why?176 (*list)[*pnumfiles] = psz; 177 strcpy((*list)[*pnumfiles], string); // Add entry 178 (*pnumfiles)++; 179 (*list)[*pnumfiles] = NULL; // Add end marker 180 (*list)[(*pnumfiles) + 1] = NULL; // Add 2nd end marker - fixme to know why? 180 181 #ifdef __DEBUG_ALLOC__ 181 182 _heap_check(); … … 189 190 PCNRITEM pci; 190 191 CHAR **list = NULL, **test; 191 INT numfiles = 0, numalloc = 0, error = 0, attribute = CRA_CURSORED; 192 UINT numfiles = 0, numalloc = 0; 193 INT error = 0, attribute = CRA_CURSORED; 192 194 193 195 pci = (PCNRITEM) CurrentRecord(hwndCnr); … … 220 222 PARCITEM pai; 221 223 CHAR **list = NULL; 222 INT numfiles = 0, numalloc = 0, error = 0, attribute = CRA_CURSORED; 224 UINT numfiles = 0, numalloc = 0; 225 INT error = 0, attribute = CRA_CURSORED; 223 226 224 227 pai = (PARCITEM) CurrentRecord(hwndCnr); … … 239 242 } 240 243 241 CHAR **RemoveFromList(CHAR ** list, CHAR *item)242 { 243 registerINT x, y;244 CHAR **RemoveFromList(CHAR **list, CHAR *item) 245 { 246 UINT x, y; 244 247 245 248 if (list && list[0] && item) { … … 264 267 } 265 268 266 CHAR **CombineLists(CHAR ** prime, CHAR **add)267 { 268 registerINT x;269 INT numalloc, numfiles = 0;269 CHAR **CombineLists(CHAR **prime, CHAR **add) 270 { 271 UINT x; 272 UINT numalloc, numfiles = 0; 270 273 271 274 if (add && add[0]) {
Note:
See TracChangeset
for help on using the changeset viewer.