| | @@ -221,17 +221,13 @@ |
| 221 | 221 | Th_Interp *interp, |
| 222 | 222 | Buffer *pBuffer, |
| 223 | 223 | const char *zAdd, |
| 224 | 224 | int nAdd |
| 225 | 225 | ){ |
| 226 | | - char *zNew; |
| 227 | 226 | int nNew = (pBuffer->nBuf+nAdd)*2+32; |
| 228 | | - zNew = (char *)Th_Malloc(interp, nNew); |
| 229 | | - th_memcpy(zNew, pBuffer->zBuf, pBuffer->nBuf); |
| 230 | | - Th_Free(interp, pBuffer->zBuf); |
| 227 | + pBuffer->zBuf = Th_Realloc(interp, pBuffer->zBuf, nNew); |
| 231 | 228 | pBuffer->nBufAlloc = nNew; |
| 232 | | - pBuffer->zBuf = zNew; |
| 233 | 229 | th_memcpy(&pBuffer->zBuf[pBuffer->nBuf], zAdd, nAdd); |
| 234 | 230 | pBuffer->nBuf += nAdd; |
| 235 | 231 | } |
| 236 | 232 | static void thBufferWriteFast( |
| 237 | 233 | Th_Interp *interp, |
| | @@ -1539,27 +1535,10 @@ |
| 1539 | 1535 | }else{ |
| 1540 | 1536 | return (char *)Th_Malloc(pInterp, 1); |
| 1541 | 1537 | } |
| 1542 | 1538 | } |
| 1543 | 1539 | |
| 1544 | | - |
| 1545 | | -/* |
| 1546 | | -** Wrappers around the supplied malloc() and free() |
| 1547 | | -*/ |
| 1548 | | -void *Th_Malloc(Th_Interp *pInterp, int nByte){ |
| 1549 | | - void *p = pInterp->pVtab->xMalloc(nByte); |
| 1550 | | - if( p ){ |
| 1551 | | - memset(p, 0, nByte); |
| 1552 | | - } |
| 1553 | | - return p; |
| 1554 | | -} |
| 1555 | | -void Th_Free(Th_Interp *pInterp, void *z){ |
| 1556 | | - if( z ){ |
| 1557 | | - pInterp->pVtab->xFree(z); |
| 1558 | | - } |
| 1559 | | -} |
| 1560 | | - |
| 1561 | 1540 | /* |
| 1562 | 1541 | ** Install a new th1 command. |
| 1563 | 1542 | ** |
| 1564 | 1543 | ** If a command of the same name already exists, it is deleted automatically. |
| 1565 | 1544 | */ |
| | @@ -1842,17 +1821,16 @@ |
| 1842 | 1821 | } |
| 1843 | 1822 | |
| 1844 | 1823 | /* |
| 1845 | 1824 | ** Create a new interpreter. |
| 1846 | 1825 | */ |
| 1847 | | -Th_Interp * Th_CreateInterp(Th_Vtab *pVtab){ |
| 1826 | +Th_Interp * Th_CreateInterp(void){ |
| 1848 | 1827 | Th_Interp *p; |
| 1849 | 1828 | |
| 1850 | 1829 | /* Allocate and initialise the interpreter and the global frame */ |
| 1851 | | - p = pVtab->xMalloc(sizeof(Th_Interp) + sizeof(Th_Frame)); |
| 1830 | + p = Th_Malloc(0, sizeof(Th_Interp) + sizeof(Th_Frame)); |
| 1852 | 1831 | memset(p, 0, sizeof(Th_Interp)); |
| 1853 | | - p->pVtab = pVtab; |
| 1854 | 1832 | p->paCmd = Th_HashNew(p); |
| 1855 | 1833 | thPushFrame(p, (Th_Frame *)&p[1]); |
| 1856 | 1834 | thInitialize(p); |
| 1857 | 1835 | |
| 1858 | 1836 | return p; |
| 1859 | 1837 | |