On 12/14/2015 5:46 PM, Bart Smissaert wrote:
> OK, thanks, will have to study this carefully.
> So, if I understand you well then the way I do it now I would need
> sqlite3_free?

First, I don't know how you do it now - you've never described that. 
Second, I have not ever said you needed sqlite3_free; nothing in your 
description of the problem so far suggests you need it.

>          'string not found, so return original field string
>          '-------------------------------------------------
> 140     If lPos = 0 Then
> 150       sqlite3_result_value lPtr_ObjContext, lPtr1
> 160       Exit Sub
> 170     End If
> 180     sqlite3_result_text lPtr_ObjContext, StrPtr(str), _
>         (lPos - 2) * 2, SQLITE_TRANSIENT

To the extent I understand what's going on (I'm not really familiar with 
VB, so I'm taking and educated guess for the most part), the memory 
management part looks OK to me.

However, I have doubts about encoding. Comments seem to suggest str 
points to a Unicode string; also the fact that you multiply lPos by 2. 
But sqlite3_result_text expects UTF-8 string. You are converting in one 
direction (SQLite to VB), but not in the other, as far as I can tell. I 
suspect you need sqlite3_result_text16 instead.

Also lPos-2 looks wrong. Can't the substring be found at lPos == 1 ?
-- 
Igor Tandetnik

Reply via email to