pike.git / src / modules / Image / font.c

version» Context lines:

pike.git/src/modules/Image/font.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: font.c,v 1.81 2003/09/10 15:21:58 mast Exp $ + || $Id: font.c,v 1.82 2003/10/07 16:21:01 mast Exp $   */      #include "global.h"      #define SPACE_CHAR 'i'      extern const unsigned char image_default_font[];   #define IMAGE_DEFAULT_FONT_SIZE 30596      
pike.git/src/modules/Image/font.c:336:    if (errno == EINTR) check_threads_etc();    } while(fd < 0 && errno == EINTR);       if (fd >= 0)    {    struct font *new_font;       size = (size_t) file_size(fd);    if (size > 0)    { -  new_font=THIS=(struct font *)xalloc(sizeof(struct font)); +  new_font=(struct font *)xalloc(sizeof(struct font));       THREADS_ALLOW();   #ifdef HAVE_MMAP    new_font->mem =    mmap(0,size,PROT_READ,MAP_SHARED,fd,0);   #ifdef MAP_FAILED    if ((char *)new_font->mem == (char *)MAP_FAILED)   #else    if (new_font->mem==(void*)-1)   #endif
pike.git/src/modules/Image/font.c:366:    fprintf(stderr,"FONT Malloced %p (%d)\n",new_font->mem,size);   #endif    if ((new_font->mem) && (!my_read(fd,new_font->mem,size)))    {    free(new_font->mem);    new_font->mem = NULL;    }   #endif    THREADS_DISALLOW();    +  if (THIS) +  /* In case font_load got called again in the THREADS_ALLOW block. */ +  free_font_struct(THIS); +  THIS = new_font; +    loading_default:       if (THIS->mem)    {    struct file_head    {    unsigned INT32 cookie;    unsigned INT32 version;    unsigned INT32 chars;    unsigned INT32 height;
pike.git/src/modules/Image/font.c:617:    case J_LEFT: xsize = 0; break;    case J_RIGHT: xsize = img->xsize-width_of[j]-1; break;    case J_CENTER: xsize = img->xsize/2-width_of[j]/2-1; break;    }    if(xsize<0) xsize=0;       switch(sp[j-args].u.string->size_shift)    {    case 0:    to_write0 = STR0(sp[j-args].u.string); -  THREADS_ALLOW(); +  /* THREADS_ALLOW(); */ +  /* Can't release the thread here; this would point to freed +  * memory if font_load gets called. We'd have to refcount font +  * structs to cope with that, but since the released window +  * typically is short and since this code isn't used much now +  * when we have Image.FreeType, I bluntly disable it instead. +  * /mast */    for (i = 0; i < to_write_len; i++)    {    c=*(to_write0++);    if (c < (INT32)this->chars)    {    if(char_width(this,c))    write_char(this->charinfo+c,    (img->img+xsize)+    (img->xsize*DOUBLE_TO_INT(j*this->height*    this->yspacing_scale)),    img->xsize,    this->height);    xsize += char_space(this, c);    }    } -  THREADS_DISALLOW(); +  /* THREADS_DISALLOW(); */    break;    case 1:    to_write1 = STR1(sp[j-args].u.string); -  THREADS_ALLOW(); +  /* THREADS_ALLOW(); */    for (i = 0; i < to_write_len; i++)    {    c=*(to_write1++);    if (c < (INT32)this->chars)    {    if(char_width(this,c))    write_char(this->charinfo+c,    (img->img+xsize)+    (img->xsize*DOUBLE_TO_INT(j*this->height*    this->yspacing_scale)),    img->xsize,    this->height);    xsize += char_space(this, c);    }    } -  THREADS_DISALLOW(); +  /* THREADS_DISALLOW(); */    break;    case 2:    to_write2 = STR2(sp[j-args].u.string); -  THREADS_ALLOW(); +  /* THREADS_ALLOW(); */    for (i = 0; i < to_write_len; i++)    {    c=*(to_write2++);    if (c < (INT32)this->chars)    {    if(char_width(this,c))    write_char(this->charinfo+c,    (img->img+xsize)+    (img->xsize*DOUBLE_TO_INT(j*this->height*    this->yspacing_scale)),    img->xsize,    this->height);    xsize += char_space(this, c);    }    } -  THREADS_DISALLOW(); +  /* THREADS_DISALLOW(); */    break;    default:    Pike_fatal("Illegal shift size!\n");    }    }    free(width_of);       pop_n_elems(args);    push_object(o);   }