MCPcopy Create free account
hub / github.com/Kitware/CMake / cmListFileLexer_SetString

Function cmListFileLexer_SetString

Source/LexerParser/cmListFileLexer.c:2836–2861  ·  view source on GitHub ↗

--------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

2834
2835/*--------------------------------------------------------------------------*/
2836int cmListFileLexer_SetString(cmListFileLexer* lexer, char const* text,
2837 size_t length)
2838{
2839 int result = 1;
2840 cmListFileLexerDestroy(lexer);
2841 /* text might be not NULL while length is 0. However, on some platforms
2842 malloc(0) will return NULL. To avoid signaling an error to the caller in
2843 such cases, ensure nonzero length. */
2844 size_t read_size = lexer->read_size - lexer->read_position;
2845 size_t string_size = read_size + length;
2846 if (string_size > 0) {
2847 lexer->string_buffer = (char*)malloc(string_size);
2848 if (lexer->string_buffer) {
2849 memcpy(lexer->string_buffer, lexer->read_buffer + lexer->read_position,
2850 read_size);
2851 memcpy(lexer->string_buffer + read_size, text, length);
2852 lexer->read_position += read_size;
2853 lexer->string_position = lexer->string_buffer;
2854 lexer->string_left = length;
2855 } else {
2856 result = 0;
2857 }
2858 }
2859 cmListFileLexerInit(lexer);
2860 return result;
2861}
2862
2863/*--------------------------------------------------------------------------*/
2864cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer)

Callers 2

LLVMFuzzerTestOneInputFunction · 0.85
ParseStringMethod · 0.85

Calls 2

cmListFileLexerDestroyFunction · 0.85
cmListFileLexerInitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…