httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saju Pillai" <saju.pil...@gmail.com>
Subject Re: understanding apr_strtok()
Date Sat, 13 Dec 2008 07:41:14 GMT
2008/12/13 Saju Pillai <saju.pillai@gmail.com>:
>
> On 13-Dec-08, at 1:02 PM, Mark Harrison wrote:
>
>> Sam Carleton wrote:
>>>
>>> I am trying to use apr_strtok() for the first time.  I am taking the
>>> add_cookie() function from mod_rewrite.c, no changes.  I am passing in
>>> the string, variable 's':
>>> KioskViewingStation:KVS_VERSION::5
>>> The first line that executes in the function is:
>>>   char *tok_cntx;
>>>   var = apr_strtok(s, ":", &tok_cntx);
>>> I am getting an access violation.  I have tried initializing tok_cntx
>>> to NULL, but that does not seem to have any impact.  What is the
>>> correct way to use apr_strtok()?
>>> Sam
>>
>> One thing you can check:
>> Make sure that s points to writable memory.
>>
>
> Check that s is on the heap not on a function stack. Try apr_pstrdup(p, s)
> or memcpy(s) into malloc'd memory.

Sorry - I meant that explicitly defined strings would usually be
stuffed into read only memory. You want to copy your string onto heap.
[ignore blabber about function stack]

-srp

>
> srp
> --
> http://saju.net.in
>

Mime
View raw message