On Monday 06 September 2010, Ruediger Pluem wrote:
> > +
> > +    /*
> > +     * The apr-util docs wrongly states encoded strings are not 
> > 0-terminated.
> > +     * Let's be save and allocate an additional byte.
> > +     */
> > +    len = 1 + apr_base64_encode_len(sizeof(id));
> > +    encoded = apr_palloc(r ? r->pool : c->pool, len);
> > +    apr_base64_encode(encoded, (char *)&id, sizeof(id));
> > +    encoded[11] = '\0'; /* omit last char which is always '=' */
> 
> Why 11 and not len?

I didn't want to depend on wether apr_base64_encode_len() includes
the terminating \0 or not. But as I am APR committer now, too, I
should probably fix the docs instead.

Besides, it would have been encoded[len-3] or encoded[len-2] which
is IMHO even less readable than encoded[11].

I have commited all your other suggestions.

Cheers,
Stefan

Reply via email to