MCPcopy Create free account
hub / github.com/KDE/kdevelop / cmListFileLexerAppend

Function cmListFileLexerAppend

plugins/cmake/parser/cmListFileLexer.c:2420–2445  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2418
2419/*--------------------------------------------------------------------------*/
2420static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
2421 int length)
2422{
2423 char* temp;
2424 int newSize;
2425
2426 /* If the appended text will fit in the buffer, do not reallocate. */
2427 newSize = lexer->token.length + length + 1;
2428 if (lexer->token.text && newSize <= lexer->size) {
2429 strcpy(lexer->token.text + lexer->token.length, text);
2430 lexer->token.length += length;
2431 return;
2432 }
2433
2434 /* We need to extend the buffer. */
2435 temp = malloc(newSize);
2436 if (lexer->token.text) {
2437 memcpy(temp, lexer->token.text, lexer->token.length);
2438 free(lexer->token.text);
2439 }
2440 memcpy(temp + lexer->token.length, text, length);
2441 temp[lexer->token.length + length] = 0;
2442 lexer->token.text = temp;
2443 lexer->token.length += length;
2444 lexer->size = newSize;
2445}
2446
2447/*--------------------------------------------------------------------------*/
2448static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,

Callers 1

cmListFileLexer.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected