Skip to content
代码片段 群组 项目
提交 f622c0ad 编辑于 作者: Yann Collet's avatar Yann Collet
浏览文件

switched UTIL_refFilename() to an assert()

上级 46bdbb9c
No related branches found
No related tags found
无相关合并请求
...@@ -372,7 +372,7 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize) ...@@ -372,7 +372,7 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize)
void UTIL_refFilename(FileNamesTable* fnt, const char* filename) void UTIL_refFilename(FileNamesTable* fnt, const char* filename)
{ {
if (fnt->tableCapacity <= fnt->tableSize) abort(); assert(fnt->tableSize < fnt->tableCapacity);
fnt->fileNames[fnt->tableSize] = filename; fnt->fileNames[fnt->tableSize] = filename;
fnt->tableSize++; fnt->tableSize++;
} }
......
...@@ -221,11 +221,10 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize); ...@@ -221,11 +221,10 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize);
/*! UTIL_refFilename() : /*! UTIL_refFilename() :
* Add a read-only name to reference into @fnt table. * Add a reference to read-only name into @fnt table.
* Since @filename is only referenced, its lifetime must outlive @fnt. * As @filename is only referenced, its lifetime must outlive @fnt.
* This function never fails, but it can abort(). * Internal table must be large enough to reference a new member,
* Internal table must be large enough to reference a new member * otherwise its UB (protected by an `assert()`).
* (capacity > size), otherwise the function will abort().
*/ */
void UTIL_refFilename(FileNamesTable* fnt, const char* filename); void UTIL_refFilename(FileNamesTable* fnt, const char* filename);
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册