src/wolfSSL/src/internal.c
void ShrinkInputBuffer(WOLFSSL* ssl, int forcedFree)
{
    int usedLength = ssl->buffers.inputBuffer.length -
                     ssl->buffers.inputBuffer.idx;
    if (!forcedFree && usedLength > STATIC_BUFFER_LEN)
        return;

    WOLFSSL_MSG("Shrinking input buffer\n");

    if (!forcedFree && usedLength)
        XMEMCPY(ssl->buffers.inputBuffer.staticBuffer,
               ssl->buffers.inputBuffer.buffer + ssl->buffers.inputBuffer.idx,
               usedLength);

    XFREE(ssl->buffers.inputBuffer.buffer - ssl->buffers.inputBuffer.offset,
          ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
    ssl->buffers.inputBuffer.buffer = ssl->buffers.inputBuffer.staticBuffer;
    ssl->buffers.inputBuffer.bufferSize  = STATIC_BUFFER_LEN;
    ssl->buffers.inputBuffer.dynamicFlag = 0;
    ssl->buffers.inputBuffer.offset      = 0;
    ssl->buffers.inputBuffer.idx = 0;
    ssl->buffers.inputBuffer.length = usedLength;
}
/* Switch dynamic input buffer back to static, keep any remaining input */
/* forced free means cleaning up */
Switch dynamic input buffer back to static, keep any remaining input
forced free means cleaning up
Switch dynamic input buffer back to static keep any remaining input forced free means cleaning up
void ShrinkInputBuffer(WOLFSSL* ssl, int forcedFree)
{
    int usedLength = ssl->buffers.inputBuffer.length -
                     ssl->buffers.inputBuffer.idx;
    if (!forcedFree && usedLength > STATIC_BUFFER_LEN)
        return;
    WOLFSSL_MSG("Shrinking input buffer\n");
    if (!forcedFree && usedLength)
        XMEMCPY(ssl->buffers.inputBuffer.staticBuffer,
               ssl->buffers.inputBuffer.buffer + ssl->buffers.inputBuffer.idx,
               usedLength);
    XFREE(ssl->buffers.inputBuffer.buffer - ssl->buffers.inputBuffer.offset,
          ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
    ssl->buffers.inputBuffer.buffer = ssl->buffers.inputBuffer.staticBuffer;
    ssl->buffers.inputBuffer.bufferSize  = STATIC_BUFFER_LEN;
    ssl->buffers.inputBuffer.dynamicFlag = 0;
    ssl->buffers.inputBuffer.offset      = 0;
    ssl->buffers.inputBuffer.idx = 0;
    ssl->buffers.inputBuffer.length = usedLength;
}
void ShrinkInputBuffer ( WOLFSSL * ssl , int forcedFree ) { int usedLength = ssl -> buffers . inputBuffer . length - ssl -> buffers . inputBuffer . idx ; if ( ! forcedFree && usedLength > STATIC_BUFFER_LEN ) return ; WOLFSSL_MSG ( " \n " ) ; if ( ! forcedFree && usedLength ) XMEMCPY ( ssl -> buffers . inputBuffer . staticBuffer , ssl -> buffers . inputBuffer . buffer + ssl -> buffers . inputBuffer . idx , usedLength ) ; XFREE ( ssl -> buffers . inputBuffer . buffer - ssl -> buffers . inputBuffer . offset , ssl -> heap , DYNAMIC_TYPE_IN_BUFFER ) ; ssl -> buffers . inputBuffer . buffer = ssl -> buffers . inputBuffer . staticBuffer ; ssl -> buffers . inputBuffer . bufferSize = STATIC_BUFFER_LEN ; ssl -> buffers . inputBuffer . dynamicFlag = 0 ; ssl -> buffers . inputBuffer . offset = 0 ; ssl -> buffers . inputBuffer . idx = 0 ; ssl -> buffers . inputBuffer . length = usedLength ; }
Switch dynamic input buffer back to static, keep any remaining input
forced free means cleaning up
Switch dynamic input buffer back to static keep any remaining input forced free means cleaning up