thomas.luebking at web.de
Thu Sep 2 21:15:54 BST 2010
This is a way to access (in this case) the last char of the previous element
(to eg. replace '\0' with ' ') but actually the particular example looks buggy
to me, since "wordlist[-1]" is NOT part of "wordlist[max_wordlist]" (which
starts at wordlist with the first char of the first string.
-> the loop should start at 1, run to words ("<=", or not, depends on what'S
intended) and access "i-1" in the second position.
So if it's not somehow guaranteed that there's NOT sth. usefull in this memory
portion, you get a mem corruption (i think, but maybe this is just beyond no
Am Thursday 02 September 2010 schrieb Jaime:
> I do not know what this methods do,
> They use a [-1] array index, perhaps to do pointer arithmetic?, but
> I do not know, it is the first time I see negative indexes in C++
> They are in kdebase/runtime/kioslave/man/man2html.cpp
> lines 2845, 3166, 3661, 3693, 3732, 3791, 4067 and 4163.
> Here you have an extract:of the first case...
> char *wordlist[max_wordlist];
> fill_words(c, wordlist, &words, true, &c);
> for (int i=0; i<words; i++)
> if ((mode) || (inFMode))
> out_html(" ");
> wordlist[i][-1]=' '; <---------------- The unknown thing for
> me out_html( set_font( (i&1) ? font2 : font1 ) );
> Best Regards.
More information about the kde-core-devel