@@ -215,6 +215,7 @@ typedef struct {
215215 int hashSize; // hash table size (power of 2)
216216 fileInPack_t* *hashTable; // hash table
217217 fileInPack_t* buildBuffer; // buffer with the filenames etc.
218+ stringPool_t* namesPool; // buffer with filenames
218219 int gvc; // game-version compatibility
219220 qboolean isJKA; // jka assets
220221} pack_t ;
@@ -1960,6 +1961,7 @@ of a zip file.
19601961static pack_t *FS_LoadZipFile ( char *zipfile, const char *basename, qboolean assetsJKA )
19611962{
19621963 fileInPack_t *buildBuffer;
1964+ stringPool_t *namesPool;
19631965 pack_t *pack;
19641966 unzFile uf;
19651967 int err;
@@ -1983,6 +1985,7 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename, qboolean ass
19831985 fs_packFiles += gi.number_entry ;
19841986
19851987 buildBuffer = (struct fileInPack_s *)Z_Malloc ((int )((gi.number_entry * sizeof (fileInPack_t))), TAG_FILESYS, qtrue);
1988+ namesPool = Z_StringPoolNew (gi.number_entry * 8 , TAG_FILESYS);
19861989 fs_headerLongs = (int *)Z_Malloc ( gi.number_entry * sizeof (int ), TAG_FILESYS, qtrue );
19871990
19881991 // get the hash table size from the number of files in the zip
@@ -2034,7 +2037,7 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename, qboolean ass
20342037 }
20352038 Q_strlwr ( filename_inzip );
20362039 hash = FS_HashFileName (filename_inzip, pack->hashSize );
2037- buildBuffer[i].name = CopyString (filename_inzip, TAG_FILESYS );
2040+ buildBuffer[i].name = Z_StringPoolAdd (namesPool, filename_inzip );
20382041 // store the file position in the zip
20392042 buildBuffer[i].pos = unzGetOffset (uf);
20402043 buildBuffer[i].len = file_info.uncompressed_size ;
@@ -2051,6 +2054,7 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename, qboolean ass
20512054 Z_Free (fs_headerLongs);
20522055
20532056 pack->buildBuffer = buildBuffer;
2057+ pack->namesPool = namesPool;
20542058
20552059 // which versions does this pk3 support?
20562060
@@ -3132,7 +3136,7 @@ static void FS_AddGameDirectory( const char *path, const char *dir, qboolean ass
31323136 if (!found) {
31333137 // server has no interest in the file
31343138 unzClose (pak->handle );
3135- Z_Free (( void *) pak->buildBuffer -> name );
3139+ Z_StringPoolFree ( pak->namesPool );
31363140 Z_Free (pak->buildBuffer );
31373141 Z_Free (pak);
31383142 continue ;
@@ -3390,7 +3394,7 @@ void FS_Shutdown( qboolean closemfp, qboolean keepModuleFiles ) {
33903394
33913395 if ( p->pack ) {
33923396 unzClose (p->pack ->handle );
3393- Z_Free ( ( void *) p->pack ->buildBuffer -> name );
3397+ Z_StringPoolFree ( p->pack ->namesPool );
33943398 Z_Free ( p->pack ->buildBuffer );
33953399 Z_Free ( p->pack );
33963400 }
0 commit comments