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. */
| 1356 | * user typed <tab>. See the example.c source code for a very easy to |
| 1357 | * understand example. */ |
| 1358 | void 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 |
no outgoing calls
no test coverage detected