|
List Info
Thread:
|
|
|
  Netherlands |
2008-05-26 20:42:42 |
I think I cannot sleep if someone doesn't pick this one up.
Could any of the core devs *verify* the correct working of
cherokee_buffer_add
Shouldn't this end up in the same output?
cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
cherokee_buffer_add_str(buf, "TEST");
In the first line, the output gets an extra garbage char.
Stefan (working hard)
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Spain |
2008-05-27 00:27:00 |
On 27 May 2008, at 03:42, Stefan de Konink wrote:
> I think I cannot sleep if someone doesn't pick this one
up.
>
> Could any of the core devs *verify* the correct working
of
> cherokee_buffer_add
>
> Shouldn't this end up in the same output?
>
> cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
I bet you meant strlen() rather than sizeof().
sizeof() gives you the total amount of memory that a certain
static
data or data type requires. In this case it returns 5
because that is
actually the memory that it needed to allocate to copy the
string:
"TEST ".
> cherokee_buffer_add_str(buf, "TEST");
Yeah, this is kind of tricky. By Cherokee's notation,
*_str() means
that the method works with an *STATIC* string. Even it they
look very
similar there is a quite big difference between static data
and
pointers to data:
/* sizeof ("hello world") = 12 */
/* strlen ("hello world") = 11 */
and
char *test = "hello world";
/* sizeof (test) = 4 */
/* strlen (test) = 11 */
.. the joys of C, you know!
> In the first line, the output gets an extra garbage
char.
I hope I've got back to you quick enough for you to have
some
sleeping
--
Greetings, alo.
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Spain |
2008-05-27 00:27:00 |
On 27 May 2008, at 03:42, Stefan de Konink wrote:
> I think I cannot sleep if someone doesn't pick this one
up.
>
> Could any of the core devs *verify* the correct working
of
> cherokee_buffer_add
>
> Shouldn't this end up in the same output?
>
> cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
I bet you meant strlen() rather than sizeof().
sizeof() gives you the total amount of memory that a certain
static
data or data type requires. In this case it returns 5
because that is
actually the memory that it needed to allocate to copy the
string:
"TEST ".
> cherokee_buffer_add_str(buf, "TEST");
Yeah, this is kind of tricky. By Cherokee's notation,
*_str() means
that the method works with an *STATIC* string. Even it they
look very
similar there is a quite big difference between static data
and
pointers to data:
/* sizeof ("hello world") = 12 */
/* strlen ("hello world") = 11 */
and
char *test = "hello world";
/* sizeof (test) = 4 */
/* strlen (test) = 11 */
.. the joys of C, you know!
> In the first line, the output gets an extra garbage
char.
I hope I've got back to you quick enough for you to have
some
sleeping
--
Greetings, alo.
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Netherlands |
2008-05-27 04:13:08 |
Alvaro Lopez Ortega schreef:
> On 27 May 2008, at 03:42, Stefan de Konink wrote:
>
>> I think I cannot sleep if someone doesn't pick this
one up.
>>
>> Could any of the core devs *verify* the correct
working of
>> cherokee_buffer_add
>>
>> Shouldn't this end up in the same output?
>>
>> cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
>
> I bet you meant strlen() rather than sizeof().
No I meant sizeof ;)
> sizeof() gives you the total amount of memory that a
certain static data
> or data type requires. In this case it returns 5
because that is
> actually the memory that it needed to allocate to copy
the string:
> "TEST ".
>
>> cherokee_buffer_add_str(buf, "TEST");
>
> Yeah, this is kind of tricky. By Cherokee's notation,
*_str() means that
> the method works with an *STATIC* string. Even it they
look very similar
> there is a quite big difference between static data and
pointers to data:
>
> /* sizeof ("hello world") = 12 */
> /* strlen ("hello world") = 11 */
>
> and
>
> char *test = "hello world";
> /* sizeof (test) = 4 */
> /* strlen (test) = 11 */
>
> .. the joys of C, you know!
>
>> In the first line, the output gets an extra garbage
char.
>
> I hope I've got back to you quick enough for you to
have some sleeping
and
I'll continue to work Thanks for
the explanation.
Stefan
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Netherlands |
2008-05-27 04:13:08 |
Alvaro Lopez Ortega schreef:
> On 27 May 2008, at 03:42, Stefan de Konink wrote:
>
>> I think I cannot sleep if someone doesn't pick this
one up.
>>
>> Could any of the core devs *verify* the correct
working of
>> cherokee_buffer_add
>>
>> Shouldn't this end up in the same output?
>>
>> cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
>
> I bet you meant strlen() rather than sizeof().
No I meant sizeof ;)
> sizeof() gives you the total amount of memory that a
certain static data
> or data type requires. In this case it returns 5
because that is
> actually the memory that it needed to allocate to copy
the string:
> "TEST ".
>
>> cherokee_buffer_add_str(buf, "TEST");
>
> Yeah, this is kind of tricky. By Cherokee's notation,
*_str() means that
> the method works with an *STATIC* string. Even it they
look very similar
> there is a quite big difference between static data and
pointers to data:
>
> /* sizeof ("hello world") = 12 */
> /* strlen ("hello world") = 11 */
>
> and
>
> char *test = "hello world";
> /* sizeof (test) = 4 */
> /* strlen (test) = 11 */
>
> .. the joys of C, you know!
>
>> In the first line, the output gets an extra garbage
char.
>
> I hope I've got back to you quick enough for you to
have some sleeping
and
I'll continue to work Thanks for
the explanation.
Stefan
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Italy |
2008-05-30 14:48:44 |
Stefan de Konink wrote:
>
> I think I cannot sleep if someone doesn't pick this one
up.
>
> Could any of the core devs *verify* the correct working
of
> cherokee_buffer_add
>
> Shouldn't this end up in the same output?
>
> cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
> cherokee_buffer_add_str(buf, "TEST");
>
> In the first line, the output gets an extra garbage
char.
Yes, as Alvaro has explained in a subsequent reply,
it's the zero terminating char.
Anyway, I think that some of cherokee_buffer_* functions
could have a better name and cherokee_buffer_add_str()
is one of these; I would use:
cherokee_buffer_add_mem()
and
cherokee_buffer_add_cstr()
to better explain the kind of arguments they take
(memory pointer + size and literal constant string).
--
Nick Name: A.D.F.
E-Mail-Format: Plain Text only (please); view using font
Courier New
--
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Italy |
2008-05-30 14:48:44 |
Stefan de Konink wrote:
>
> I think I cannot sleep if someone doesn't pick this one
up.
>
> Could any of the core devs *verify* the correct working
of
> cherokee_buffer_add
>
> Shouldn't this end up in the same output?
>
> cherokee_buffer_add(buf, "TEST",
sizeof("TEST"));
> cherokee_buffer_add_str(buf, "TEST");
>
> In the first line, the output gets an extra garbage
char.
Yes, as Alvaro has explained in a subsequent reply,
it's the zero terminating char.
Anyway, I think that some of cherokee_buffer_* functions
could have a better name and cherokee_buffer_add_str()
is one of these; I would use:
cherokee_buffer_add_mem()
and
cherokee_buffer_add_cstr()
to better explain the kind of arguments they take
(memory pointer + size and literal constant string).
--
Nick Name: A.D.F.
E-Mail-Format: Plain Text only (please); view using font
Courier New
--
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Spain |
2008-05-30 14:34:00 |
On 30 May 2008, at 21:48, A.D.F. wrote:
>
> Anyway, I think that some of cherokee_buffer_*
functions
> could have a better name and cherokee_buffer_add_str()
> is one of these; I would use:
>
> cherokee_buffer_add_mem()
> and
> cherokee_buffer_add_cstr()
>
> to better explain the kind of arguments they take
> (memory pointer + size and literal constant string).
That's a good point, actually.
I do agree on renaming cherokee_buffer_add_str() to
cherokee_buffer_add_literal(), cherokee_buffer_add_lit() or
something
similar. The 'str' suffix does not describe it properly,
that is clear.
--
Greetings, alo.
http://www.alobbs.com/
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
| Re: |
  Spain |
2008-05-30 14:34:00 |
On 30 May 2008, at 21:48, A.D.F. wrote:
>
> Anyway, I think that some of cherokee_buffer_*
functions
> could have a better name and cherokee_buffer_add_str()
> is one of these; I would use:
>
> cherokee_buffer_add_mem()
> and
> cherokee_buffer_add_cstr()
>
> to better explain the kind of arguments they take
> (memory pointer + size and literal constant string).
That's a good point, actually.
I do agree on renaming cherokee_buffer_add_str() to
cherokee_buffer_add_literal(), cherokee_buffer_add_lit() or
something
similar. The 'str' suffix does not describe it properly,
that is clear.
--
Greetings, alo.
http://www.alobbs.com/
_______________________________________________
Cherokee mailing list
Cherokee cherokee-project.com
http://cherokee-project.com/cgi-bin/mailman/listinf
o/cherokee
|
|
[1-9]
|
|