diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-13 15:41:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-13 15:41:24 +0400 |
commit | 030e5bd93ee0aaea3e43b89fb87191d7ec45c3be (patch) | |
tree | aaf822efb43b8d44a3c3e9a2c67d939d867c3ebb /source | |
parent | b5eff581bc5fc5eb66b2c168b091387a0160b710 (diff) |
Drawing a string longer then 255 chars wasnt working.
changes to flatten_string_append(...), probably only brecht is interested.
- It was copying from the old malloc'd buffer but never the fixed buffer - the reason >255 length strings didnt render.
- on first malloc for the FlatString allocate 512 rather then 256 chars since the fixed string is 256 chars.
- if the char was '\0' fs->pos was set to 0, not sure why since char cant be '\0' because of the loop that calls flatten_string_append, removed.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 9f8cedd569f..9721fbc2b9c 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -109,22 +109,18 @@ static void flatten_string_append(FlattenString *fs, char c, int accum) { if(fs->pos>=fs->len && fs->pos>=sizeof(fs->fixedbuf)-1) { char *nbuf; int *naccum; - int olen= fs->len; - - if(olen) fs->len*= 2; - else fs->len= 256; - + if(fs->len) fs->len*= 2; + else fs->len= sizeof(fs->fixedbuf) * 2; + nbuf= MEM_callocN(sizeof(*fs->buf)*fs->len, "fs->buf"); naccum= MEM_callocN(sizeof(*fs->accum)*fs->len, "fs->accum"); + + memcpy(nbuf, fs->buf, fs->pos); + memcpy(naccum, fs->accum, fs->pos); - if(olen) { - memcpy(nbuf, fs->buf, olen); - memcpy(naccum, fs->accum, olen); - - if(fs->buf != fs->fixedbuf) { - MEM_freeN(fs->buf); - MEM_freeN(fs->accum); - } + if(fs->buf != fs->fixedbuf) { + MEM_freeN(fs->buf); + MEM_freeN(fs->accum); } fs->buf= nbuf; @@ -134,8 +130,7 @@ static void flatten_string_append(FlattenString *fs, char c, int accum) fs->buf[fs->pos]= c; fs->accum[fs->pos]= accum; - if(c==0) fs->pos= 0; - else fs->pos++; + fs->pos++; } int flatten_string(SpaceText *st, FlattenString *fs, char *in) @@ -1336,6 +1331,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) UI_ThemeColor(TH_TEXT); sprintf(linenr, "%d", i + linecount + 1); + /* itoa(i + linecount + 1, linenr, 10); */ /* not ansi-c :/ */ text_font_draw(st, TXT_OFFSET - 7, y, linenr); UI_ThemeColor(TH_TEXT); |