MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / linenoiseAddCompletion

Function linenoiseAddCompletion

tools/shell/linenoise.cpp:1358–1373  ·  view source on GitHub ↗

This function is used by the callback function registered by the user * in order to add completion options given the input string when the * user typed . See the example.c source code for a very easy to * understand example. */

Source from the content-addressed store, hash-verified

1356 * user typed <tab>. See the example.c source code for a very easy to
1357 * understand example. */
1358void linenoiseAddCompletion(linenoiseCompletions* lc, const char* str) {
1359 size_t len = strlen(str);
1360 char *copy, **cvec;
1361
1362 copy = (char*)malloc(len + 1);
1363 if (copy == NULL)
1364 return;
1365 memcpy(copy, str, len + 1);
1366 cvec = (char**)realloc(lc->cvec, sizeof(char*) * (lc->len + 1));
1367 if (cvec == NULL) {
1368 free(copy);
1369 return;
1370 }
1371 lc->cvec = cvec;
1372 lc->cvec[lc->len++] = copy;
1373}
1374
1375/* =========================== Line editing ================================= */
1376

Callers 3

addTableCompletionFunction · 0.85
keywordCompletionFunction · 0.85
completionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected