NOEXPORT void win_log(LPCTSTR txt) {
    struct LIST *curr;
    size_t txt_len;
    static size_t log_len=0;

    txt_len=_tcslen(txt);
    curr=str_alloc_detached(sizeof(struct LIST)+txt_len*sizeof(TCHAR));
    curr->len=txt_len;
    _tcscpy(curr->txt, txt);
    curr->next=NULL;

    /* this critical section is performance critical */
    CRYPTO_THREAD_write_lock(stunnel_locks[LOCK_WIN_LOG]);
    if(tail)
        tail->next=curr;
    tail=curr;
    if(!head)
        head=tail;
    log_len++;
    new_logs=TRUE;
    if(log_len>LOG_LINES) {
        curr=head;
        head=head->next;
        log_len--;
    } else {
        curr=NULL;
    }
    CRYPTO_THREAD_unlock(stunnel_locks[LOCK_WIN_LOG]);

    str_free(curr);
}
NOEXPORT void win_log(LPCTSTR txt) {
    struct LIST *curr;
    size_t txt_len;
    static size_t log_len=0;

    txt_len=_tcslen(txt);
    curr=str_alloc_detached(sizeof(struct LIST)+txt_len*sizeof(TCHAR));
    curr->len=txt_len;
    _tcscpy(curr->txt, txt);
    curr->next=NULL;

     
    CRYPTO_THREAD_write_lock(stunnel_locks[LOCK_WIN_LOG]);
    if(tail)
        tail->next=curr;
    tail=curr;
    if(!head)
        head=tail;
    log_len++;
    new_logs=TRUE;
    if(log_len>LOG_LINES) {
        curr=head;
        head=head->next;
        log_len--;
    } else {
        curr=NULL;
    }
    CRYPTO_THREAD_unlock(stunnel_locks[LOCK_WIN_LOG]);

    str_free(curr);
}