hist_enlargebuf() * Enlarge history buffer to specified value. Called from el_enlargebufs(). * Return 0 for failure, 1 for success. */
| 191 | * Return 0 for failure, 1 for success. |
| 192 | */ |
| 193 | protected int |
| 194 | /*ARGSUSED*/ |
| 195 | hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz) |
| 196 | { |
| 197 | Char *newbuf; |
| 198 | |
| 199 | newbuf = el_realloc(el->el_history.buf, newsz * sizeof(*newbuf)); |
| 200 | if (!newbuf) |
| 201 | return 0; |
| 202 | |
| 203 | (void) memset(&newbuf[oldsz], '\0', (newsz - oldsz) * sizeof(*newbuf)); |
| 204 | |
| 205 | el->el_history.last = newbuf + |
| 206 | (el->el_history.last - el->el_history.buf); |
| 207 | el->el_history.buf = newbuf; |
| 208 | el->el_history.sz = newsz; |
| 209 | |
| 210 | return 1; |
| 211 | } |
| 212 | |
| 213 | #ifdef WIDECHAR |
| 214 | protected wchar_t * |