copyright.
+2005-06-24 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * dvi/mdvi-lib/bitmap.c: (bitmap_alloc), (bitmap_alloc_raw),
+ (bitmap_flip_horizontally), (bitmap_flip_vertically),
+ (bitmap_flip_diagonally), (bitmap_rotate_clockwise),
+ (bitmap_rotate_counter_clockwise), (bitmap_flip_rotate_clockwise),
+ (bitmap_flip_rotate_counter_clockwise):
+ * dvi/mdvi-lib/color.c: (mdvi_push_color), (get_color_table):
+ * dvi/mdvi-lib/common.c: (read_string), (buff_free), (buff_add),
+ (buff_gets):
+ * dvi/mdvi-lib/common.h:
+ * dvi/mdvi-lib/dvimisc.c: (mdvi_push_color):
+ * dvi/mdvi-lib/dviread.c: (get_bytes), (dreset), (define_font),
+ (opendvi), (mdvi_reload), (mdvi_init_context),
+ (mdvi_destroy_context), (mdvi_dopage), (special):
+ * dvi/mdvi-lib/font.c: (font_drop_one), (font_free_unused):
+ * dvi/mdvi-lib/fontmap.c: (read_encoding), (destroy_encoding),
+ (file_hash_free), (register_encoding), (parse_spec),
+ (mdvi_load_fontmap), (free_ent), (mdvi_init_fontmaps),
+ (mdvi_add_fontmap_file), (mdvi_ps_read_fontmap),
+ (mdvi_ps_flush_fonts), (mdvi_ps_find_font), (mdvi_ps_get_metrics):
+ * dvi/mdvi-lib/fontsrch.c: (mdvi_list_font_class),
+ (mdvi_register_font_type), (mdvi_unregister_font_type),
+ (lookup_font), (mdvi_add_font), (mdvi_font_retry):
+ * dvi/mdvi-lib/gf.c: (gf_read_bitmap), (gf_load_font):
+ * dvi/mdvi-lib/hash.c: (mdvi_hash_remove), (mdvi_hash_remove_ptr),
+ (mdvi_hash_destroy_key), (mdvi_hash_reset):
+ * dvi/mdvi-lib/pagesel.c: (mdvi_parse_range),
+ (mdvi_parse_page_spec), (mdvi_free_page_spec), (main):
+ * dvi/mdvi-lib/paper.c: (mdvi_free_paper_specs):
+ * dvi/mdvi-lib/pk.c: (pk_lookup), (pk_lookupn), (pk_load_font):
+ * dvi/mdvi-lib/sp-epsf.c: (epsf_special):
+ * dvi/mdvi-lib/special.c: (mdvi_register_special),
+ (mdvi_unregister_special), (mdvi_flush_specials):
+ * dvi/mdvi-lib/t1.c: (t1_lookup_font), (t1_really_load_font),
+ (t1_font_remove):
+ * dvi/mdvi-lib/tfm.c: (get_tfm_chars):
+ * dvi/mdvi-lib/tfmfile.c: (afm_load_file), (tfm_load_file),
+ (ofm1_load_file), (ofm_load_file), (get_font_metrics),
+ (free_font_metrics), (flush_font_metrics):
+ * dvi/mdvi-lib/tt.c: (tt_really_load_font), (tt_get_bitmap),
+ (tt_font_remove):
+ * dvi/mdvi-lib/util.c: (mdvi_malloc), (mdvi_realloc),
+ (mdvi_calloc), (mdvi_free), (mdvi_strdup), (mdvi_strncpy),
+ (mdvi_strndup), (mdvi_memdup), (xstradd), (dstring_append),
+ (dstring_insert), (dstring_new), (dstring_reset):
+ * dvi/mdvi-lib/vf.c: (vf_load_font), (vf_free_macros):
+
+ Rename xmalloc and xfree to mdvi_malloc and mdvi_free to
+ avoid conflict with libtool on FC4
+
+ * shell/ev-window.c: (ev_window_cmd_help_about):
+
+ Update copyright year. Fix for bug 308828.
+
2005-06-23 Nikolay V. Shmyrev <nshmyrev@yandex.ru>
* shell/ev-view.c: (add_scroll_binding_keypad),
bm->height = h;
bm->stride = BM_BYTES_PER_LINE(bm);
if(h && bm->stride)
- bm->data = (BmUnit *)xcalloc(h, bm->stride);
+ bm->data = (BmUnit *)mdvi_calloc(h, bm->stride);
else
bm->data = NULL;
bm->height = h;
bm->stride = BM_BYTES_PER_LINE(bm);
if(h && bm->stride)
- bm->data = (BmUnit *)xmalloc(h * bm->stride);
+ bm->data = (BmUnit *)mdvi_malloc(h * bm->stride);
else
bm->data = NULL;
nb.width = bm->width;
nb.height = bm->height;
nb.stride = bm->stride;
- nb.data = xcalloc(bm->height, bm->stride);
+ nb.data = mdvi_calloc(bm->height, bm->stride);
fptr = bm->data;
tptr = __bm_unit_ptr(&nb, nb.width-1, 0);
}
DEBUG((DBG_BITMAP_OPS, "flip_horizontally (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
if(SHOW_OP_DATA)
bitmap_print(stderr, bm);
nb.width = bm->width;
nb.height = bm->height;
nb.stride = bm->stride;
- nb.data = xcalloc(bm->height, bm->stride);
+ nb.data = mdvi_calloc(bm->height, bm->stride);
fptr = bm->data;
tptr = __bm_unit_ptr(&nb, 0, nb.height-1);
}
DEBUG((DBG_BITMAP_OPS, "flip_vertically (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
if(SHOW_OP_DATA)
bitmap_print(stderr, bm);
nb.width = bm->width;
nb.height = bm->height;
nb.stride = bm->stride;
- nb.data = xcalloc(bm->height, bm->stride);
+ nb.data = mdvi_calloc(bm->height, bm->stride);
fptr = bm->data;
tptr = __bm_unit_ptr(&nb, nb.width-1, nb.height-1);
}
DEBUG((DBG_BITMAP_OPS, "flip_diagonally (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
if(SHOW_OP_DATA)
bitmap_print(stderr, bm);
nb.width = bm->height;
nb.height = bm->width;
nb.stride = BM_BYTES_PER_LINE(&nb);
- nb.data = xcalloc(nb.height, nb.stride);
+ nb.data = mdvi_calloc(nb.height, nb.stride);
fptr = bm->data;
tptr = __bm_unit_ptr(&nb, nb.width - 1, 0);
DEBUG((DBG_BITMAP_OPS, "rotate_clockwise (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
bm->width = nb.width;
bm->height = nb.height;
nb.width = bm->height;
nb.height = bm->width;
nb.stride = BM_BYTES_PER_LINE(&nb);
- nb.data = xcalloc(nb.height, nb.stride);
+ nb.data = mdvi_calloc(nb.height, nb.stride);
fptr = bm->data;
tptr = __bm_unit_ptr(&nb, 0, nb.height - 1);
DEBUG((DBG_BITMAP_OPS, "rotate_counter_clockwise (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
bm->width = nb.width;
bm->height = nb.height;
nb.width = bm->height;
nb.height = bm->width;
nb.stride = BM_BYTES_PER_LINE(&nb);
- nb.data = xcalloc(nb.height, nb.stride);
+ nb.data = mdvi_calloc(nb.height, nb.stride);
fptr = bm->data;
tptr = __bm_unit_ptr(&nb, nb.width-1, nb.height-1);
}
DEBUG((DBG_BITMAP_OPS, "flip_rotate_clockwise (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
bm->width = nb.width;
bm->height = nb.height;
nb.width = bm->height;
nb.height = bm->width;
nb.stride = BM_BYTES_PER_LINE(&nb);
- nb.data = xcalloc(nb.height, nb.stride);
+ nb.data = mdvi_calloc(nb.height, nb.stride);
fptr = bm->data;
tptr = nb.data;
DEBUG((DBG_BITMAP_OPS, "flip_rotate_counter_clockwise (%d,%d) -> (%d,%d)\n",
bm->width, bm->height, nb.width, nb.height));
- xfree(bm->data);
+ mdvi_free(bm->data);
bm->data = nb.data;
bm->width = nb.width;
bm->height = nb.height;
{
if(dvi->color_top == dvi->color_size) {
dvi->color_size += 32;
- dvi->color_stack = xrealloc(dvi->color_stack,
+ dvi->color_stack = mdvi_realloc(dvi->color_stack,
dvi->color_size * sizeof(DviColorPair));
}
dvi->color_stack[dvi->color_top].fg = dvi->curr_fg;
cc->pixels = NULL;
} else {
cc = tofree;
- xfree(cc->pixels);
+ mdvi_free(cc->pixels);
}
pixels = xnalloc(Ulong, nlevels);
status = dev->alloc_colors(dev->device_data,
pixels, nlevels, fg, bg, gamma, density);
if(status < 0) {
- xfree(pixels);
+ mdvi_free(pixels);
return NULL;
}
cc->fg = fg;
n = fugetn(in, s ? s : 1);
if((str = buffer) == NULL || n + 1 > len)
- str = xmalloc(n + 1);
+ str = mdvi_malloc(n + 1);
if(fread(str, 1, n, in) != n) {
- if(str != buffer) xfree(str);
+ if(str != buffer) mdvi_free(str);
return NULL;
}
str[n] = 0;
void buff_free(Buffer *buf)
{
if(buf->data)
- xfree(buf->data);
+ mdvi_free(buf->data);
buff_init(buf);
}
len = strlen(data);
if(buf->length + len + 1 > buf->size) {
buf->size = buf->length + len + 256;
- buf->data = xrealloc(buf->data, buf->size);
+ buf->data = mdvi_realloc(buf->data, buf->size);
}
memcpy(buf->data + buf->length, data, len);
buf->length += len;
return NULL;
ptr++; /* include newline */
len = ptr - buf->data;
- ret = xmalloc(len + 1);
+ ret = mdvi_malloc(len + 1);
if(len > 0) {
memcpy(ret, buf->data, len);
memmove(buf->data, buf->data + len, buf->length - len);
/* memory allocation */
-extern void xfree __PROTO((void *));
-extern void *xmalloc __PROTO((size_t));
-extern void *xrealloc __PROTO((void *, size_t));
-extern void *xcalloc __PROTO((size_t, size_t));
-extern char *xstrncpy __PROTO((char *, const char *, size_t));
-extern char *xstrdup __PROTO((const char *));
-extern char *xstrndup __PROTO((const char *, size_t));
-extern void *xmemdup __PROTO((const void *, size_t));
+extern void mdvi_free __PROTO((void *));
+extern void *mdvi_malloc __PROTO((size_t));
+extern void *mdvi_realloc __PROTO((void *, size_t));
+extern void *mdvi_calloc __PROTO((size_t, size_t));
+extern char *mdvi_strncpy __PROTO((char *, const char *, size_t));
+extern char *mdvi_strdup __PROTO((const char *));
+extern char *mdvi_strndup __PROTO((const char *, size_t));
+extern void *mdvi_memdup __PROTO((const void *, size_t));
/* macros to make memory allocation nicer */
-#define xalloc(t) (t *)xmalloc(sizeof(t))
-#define xnalloc(t,n) (t *)xcalloc((n), sizeof(t))
-#define xresize(p,t,n) (t *)xrealloc((p), (n) * sizeof(t))
+#define xalloc(t) (t *)mdvi_malloc(sizeof(t))
+#define xnalloc(t,n) (t *)mdvi_calloc((n), sizeof(t))
+#define xresize(p,t,n) (t *)mdvi_realloc((p), (n) * sizeof(t))
extern char *xstradd __PROTO((char *, size_t *, size_t, const char *, size_t));
{
if(dvi->color_top == dvi->color_size) {
dvi->color_size += 32;
- dvi->color_stack = xrealloc(dvi->color_stack,
+ dvi->color_stack = mdvi_realloc(dvi->color_stack,
dvi->color_size * sizeof(DviColorPair));
}
dvi->color_stack[dvi->color_top].fg = dvi->curr_fg;
if(dvi->buffer.data == NULL) {
/* first allocation */
dvi->buffer.size = Max(DVI_BUFLEN, n);
- dvi->buffer.data = (Uchar *)xmalloc(dvi->buffer.size);
+ dvi->buffer.data = (Uchar *)mdvi_malloc(dvi->buffer.size);
dvi->buffer.length = 0;
dvi->buffer.frozen = 0;
} else if(dvi->buffer.pos < dvi->buffer.length) {
static void dreset(DviContext *dvi)
{
if(!dvi->buffer.frozen && dvi->buffer.data)
- xfree(dvi->buffer.data);
+ mdvi_free(dvi->buffer.data);
dvi->buffer.data = NULL;
dvi->buffer.size = 0;
dvi->buffer.length = 0;
hdpi = FROUND(dvi->params.mag * dvi->params.dpi * scale / dsize);
vdpi = FROUND(dvi->params.mag * dvi->params.vdpi * scale / dsize);
n = duget1(dvi) + duget1(dvi);
- name = xmalloc(n + 1);
+ name = mdvi_malloc(n + 1);
dread(dvi, name, n);
name[n] = 0;
DEBUG((DBG_FONTS, "requesting font %d = `%s' at %.1fpt (%dx%d dpi)\n",
ref = font_reference(&dvi->params, arg, name, checksum, hdpi, vdpi, scale);
if(ref == NULL) {
error(_("could not load font `%s'\n"), name);
- xfree(name);
+ mdvi_free(name);
return NULL;
}
- xfree(name);
+ mdvi_free(name);
return ref;
}
if(len >= 4 && STREQ(name+len-4, ".dvi")) {
DEBUG((DBG_DVI|DBG_FILES, "opendvi: Trying `%s'\n", name));
if(access(name, R_OK) == 0)
- return xstrdup(name);
+ return mdvi_strdup(name);
}
/* try appending .dvi */
- file = xmalloc(len + 5);
+ file = mdvi_malloc(len + 5);
strcpy(file, name);
strcpy(file+len, ".dvi");
DEBUG((DBG_DVI|DBG_FILES, "opendvi: Trying `%s'\n", file));
DEBUG((DBG_DVI|DBG_FILES, "opendvi: Trying `%s'\n", file));
if(access(file, R_OK) == 0)
return file;
- xfree(file);
+ mdvi_free(file);
return NULL;
}
font_drop_chain(dvi->fonts);
/* destroy our font map */
if(dvi->fontmap)
- xfree(dvi->fontmap);
+ mdvi_free(dvi->fontmap);
dvi->currfont = NULL;
/* and use the ones we just loaded */
dvi->dvivconv = newdvi->dvivconv;
dvi->modtime = newdvi->modtime;
- if(dvi->fileid) xfree(dvi->fileid);
+ if(dvi->fileid) mdvi_free(dvi->fileid);
dvi->fileid = newdvi->fileid;
dvi->dvi_page_w = newdvi->dvi_page_w;
dvi->dvi_page_h = newdvi->dvi_page_h;
- xfree(dvi->pagemap);
+ mdvi_free(dvi->pagemap);
dvi->pagemap = newdvi->pagemap;
dvi->npages = newdvi->npages;
if(dvi->currpage > dvi->npages-1)
dvi->currpage = 0;
- xfree(dvi->stack);
+ mdvi_free(dvi->stack);
dvi->stack = newdvi->stack;
dvi->stacksize = newdvi->stacksize;
/* remove fonts that are not being used anymore */
font_free_unused(&dvi->device);
- xfree(newdvi->filename);
- xfree(newdvi);
+ mdvi_free(newdvi->filename);
+ mdvi_free(newdvi);
DEBUG((DBG_DVI, "%s: reload successful\n", dvi->filename));
if(dvi->device.refresh)
p = fopen(filename, "r");
if(p == NULL) {
perror(file);
- xfree(filename);
+ mdvi_free(filename);
return NULL;
}
dvi = xalloc(DviContext);
/* get the comment from the preamble */
n = fuget1(p);
- dvi->fileid = xmalloc(n + 1);
+ dvi->fileid = mdvi_malloc(n + 1);
fread(dvi->fileid, 1, n, p);
dvi->fileid[n] = 0;
DEBUG((DBG_DVI, "%s: %s\n", filename, dvi->fileid));
font_free_unused(&dvi->device);
}
if(dvi->fontmap)
- xfree(dvi->fontmap);
+ mdvi_free(dvi->fontmap);
if(dvi->filename)
- xfree(dvi->filename);
+ mdvi_free(dvi->filename);
if(dvi->stack)
- xfree(dvi->stack);
+ mdvi_free(dvi->stack);
if(dvi->pagemap)
- xfree(dvi->pagemap);
+ mdvi_free(dvi->pagemap);
if(dvi->fileid)
- xfree(dvi->fileid);
+ mdvi_free(dvi->fileid);
if(dvi->in)
fclose(dvi->in);
if(dvi->buffer.data && !dvi->buffer.frozen)
- xfree(dvi->buffer.data);
+ mdvi_free(dvi->buffer.data);
if(dvi->color_stack)
- xfree(dvi->color_stack);
+ mdvi_free(dvi->color_stack);
- xfree(dvi);
+ mdvi_free(dvi);
}
void mdvi_setpage(DviContext *dvi, int pageno)
dvi->curr_layer = 0;
if(dvi->buffer.data && !dvi->buffer.frozen)
- xfree(dvi->buffer.data);
+ mdvi_free(dvi->buffer.data);
/* reset our buffer */
dvi->buffer.data = NULL;
Int32 arg;
arg = dugetn(dvi, opcode - DVI_XXX1 + 1);
- s = xmalloc(arg + 1);
+ s = mdvi_malloc(arg + 1);
dread(dvi, s, arg);
s[arg] = 0;
mdvi_do_special(dvi, s);
SHOWCMD((dvi, "XXXX", opcode - DVI_XXX1 + 1,
"[%s]", s));
- xfree(s);
+ mdvi_free(s);
return 0;
}
DviFont *font;
font = ref->ref;
- xfree(ref);
+ mdvi_free(ref);
/* drop all children */
for(ref = font->subfonts; ref; ref = ref->next) {
/* just adjust the reference counts */
/* get rid of subfonts (but can't use `drop_chain' here) */
for(; (ref = font->subfonts); ) {
font->subfonts = ref->next;
- xfree(ref);
+ mdvi_free(ref);
}
/* remove this font */
font_reset_font_glyphs(dev, font, MDVI_FONTSEL_GLYPH);
font->finfo->freedata(font);
/* destroy characters */
if(font->chars)
- xfree(font->chars);
- xfree(font->fontname);
- xfree(font->filename);
- xfree(font);
+ mdvi_free(font->chars);
+ mdvi_free(font->fontname);
+ mdvi_free(font->filename);
+ mdvi_free(font);
}
DEBUG((DBG_FONTS, "%d unused fonts removed\n", count));
return count;
/* setup the hash table */
mdvi_hash_create(&enc->nametab, ENCNAME_HASH_SIZE);
/* setup the encoding vector */
- enc->vector = (char **)xmalloc(256 * sizeof(char *));
+ enc->vector = (char **)mdvi_malloc(256 * sizeof(char *));
/* jump to the beginning of the interesting part */
fseek(in, enc->offset, SEEK_SET);
/* and read everything */
if(fread(enc->private, st.st_size, 1, in) != 1) {
fclose(in);
- xfree(enc->private);
+ mdvi_free(enc->private);
enc->private = NULL;
return -1;
}
}
if(curr == 0) {
mdvi_hash_reset(&enc->nametab, 0);
- xfree(enc->private);
- xfree(enc);
+ mdvi_free(enc->private);
+ mdvi_free(enc);
return -1;
}
while(curr < 256)
if(enc != tex_text_encoding) {
mdvi_hash_reset(&enc->nametab, 0);
if(enc->private) {
- xfree(enc->private);
- xfree(enc->vector);
+ mdvi_free(enc->private);
+ mdvi_free(enc->vector);
}
if(enc->name)
- xfree(enc->name);
+ mdvi_free(enc->name);
if(enc->filename)
- xfree(enc->filename);
- xfree(enc);
+ mdvi_free(enc->filename);
+ mdvi_free(enc);
}
}
/* this is used for the `enctable_file' hash table */
static void file_hash_free(DviHashKey key, void *data)
{
- xfree(key);
+ mdvi_free(key);
}
static DviEncoding *register_encoding(const char *basefile, int replace)
/* finally try the given name */
if(filename == NULL)
- filename = xstrdup(basefile);
+ filename = mdvi_strdup(basefile);
in = fopen(filename, "r");
if(in == NULL) {
- xfree(filename);
+ mdvi_free(filename);
return NULL;
}
DEBUG((DBG_FMAP,
"%s: could not determine name of encoding\n",
basefile));
- xfree(filename);
+ mdvi_free(filename);
return NULL;
}
} else if(enc) {
/* if the encoding is being used, refuse to remove it */
if(enc->links) {
- xfree(filename);
+ mdvi_free(filename);
dstring_reset(&input);
return NULL;
}
DEBUG((DBG_FMAP, "%s: overriding encoding\n", name));
destroy_encoding(enc);
} else {
- xfree(filename);
+ mdvi_free(filename);
dstring_reset(&input);
return enc; /* no error */
}
}
enc = xalloc(DviEncoding);
- enc->name = xstrdup(name);
+ enc->name = mdvi_strdup(name);
enc->filename = filename;
enc->links = 0;
enc->offset = offset;
default_encoding = enc;
mdvi_hash_add(&enctable, MDVI_KEY(enc->name),
enc, MDVI_HASH_UNCHECKED);
- mdvi_hash_add(&enctable_file, MDVI_KEY(xstrdup(basefile)),
+ mdvi_hash_add(&enctable_file, MDVI_KEY(mdvi_strdup(basefile)),
enc, MDVI_HASH_REPLACE);
listh_prepend(&encodings, LIST(enc));
DEBUG((DBG_FMAP, "%s: encoding `%s' registered\n",
ent->extend = SFROUND(x);
} else if(STREQ(command, "ReEncodeFont")) {
if(ent->encoding)
- xfree(ent->encoding);
- ent->encoding = xstrdup(arg);
+ mdvi_free(ent->encoding);
+ ent->encoding = mdvi_strdup(arg);
}
}
}
in = fopen(file, "r");
else {
in = fopen(ptr, "r");
- xfree(ptr);
+ mdvi_free(ptr);
}
if(in == NULL)
return NULL;
if(tex_name == NULL)
continue;
- ent->fontname = xstrdup(tex_name);
- ent->psname = ps_name ? xstrdup(ps_name) : NULL;
- ent->fontfile = font_file ? xstrdup(font_file) : NULL;
- ent->encfile = vec_name ? xstrdup(vec_name) : NULL;
+ ent->fontname = mdvi_strdup(tex_name);
+ ent->psname = ps_name ? mdvi_strdup(ps_name) : NULL;
+ ent->fontfile = font_file ? mdvi_strdup(font_file) : NULL;
+ ent->encfile = vec_name ? mdvi_strdup(vec_name) : NULL;
ent->fullfile = NULL;
enc = NULL; /* we don't have this yet */
_("%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n"),
file, lineno);
} else if(!ent->encoding)
- ent->encoding = xstrdup(enc->name);
+ ent->encoding = mdvi_strdup(enc->name);
}
/* add it to the list */
static void free_ent(DviFontMapEnt *ent)
{
ASSERT(ent->fontname != NULL);
- xfree(ent->fontname);
+ mdvi_free(ent->fontname);
if(ent->psname)
- xfree(ent->psname);
+ mdvi_free(ent->psname);
if(ent->fontfile)
- xfree(ent->fontfile);
+ mdvi_free(ent->fontfile);
if(ent->encoding)
- xfree(ent->encoding);
+ mdvi_free(ent->encoding);
if(ent->encfile)
- xfree(ent->encfile);
+ mdvi_free(ent->encfile);
if(ent->fullfile)
- xfree(ent->fullfile);
- xfree(ent);
+ mdvi_free(ent->fullfile);
+ mdvi_free(ent);
}
void mdvi_install_fontmap(DviFontMapEnt *head)
in = fopen(config, "r");
else {
in = fopen(file, "r");
- xfree(file);
+ mdvi_free(file);
}
if(in == NULL)
return -1;
if(!psinitialized)
ps_init_default_paths();
if(psfontdir)
- xfree(psfontdir);
+ mdvi_free(psfontdir);
psfontdir = kpse_path_expand(arg);
} else if(STRNEQ(line, "pslibpath", 9)) {
arg = getstring(line + 10, " \t", &line); *line = 0;
if(!psinitialized)
ps_init_default_paths();
if(pslibdir)
- xfree(pslibdir);
+ mdvi_free(pslibdir);
pslibdir = kpse_path_expand(arg);
} else if(STRNEQ(line, "psfontmap", 9)) {
arg = getstring(line + 9, " \t", &line); *line = 0;
if(ent == NULL)
return -1;
if(ent->fullfile)
- xfree(ent->fullfile);
- ent->fullfile = xstrdup(fullpath);
+ mdvi_free(ent->fullfile);
+ ent->fullfile = mdvi_strdup(fullpath);
return 0;
}
in = fopen(fullname, "r");
if(in == NULL) {
if(fullname != name)
- xfree(fullname);
+ mdvi_free(fullname);
return -1;
}
dstring_init(&dstr);
DEBUG((DBG_FMAP,
"(ps) replacing font `%s' (%s) by `%s'\n",
name, ps->mapname, mapname));
- xfree(ps->mapname);
- ps->mapname = xstrdup(mapname);
+ mdvi_free(ps->mapname);
+ ps->mapname = mdvi_strdup(mapname);
if(ps->fullname) {
- xfree(ps->fullname);
+ mdvi_free(ps->fullname);
ps->fullname = NULL;
}
} else {
DEBUG((DBG_FMAP, "(ps) adding font `%s' as `%s'\n",
name, mapname));
ps = xalloc(PSFontMap);
- ps->psname = xstrdup(name);
- ps->mapname = xstrdup(mapname);
+ ps->psname = mdvi_strdup(name);
+ ps->mapname = mdvi_strdup(mapname);
ps->fullname = NULL;
listh_append(&psfonts, LIST(ps));
mdvi_hash_add(&pstable, MDVI_KEY(ps->psname),
mdvi_hash_reset(&pstable, 0);
for(; (map = (PSFontMap *)psfonts.head); ) {
psfonts.head = LIST(map->next);
- xfree(map->psname);
- xfree(map->mapname);
+ mdvi_free(map->psname);
+ mdvi_free(map->mapname);
if(map->fullname)
- xfree(map->fullname);
- xfree(map);
+ mdvi_free(map->fullname);
+ mdvi_free(map);
}
listh_init(&psfonts);
if(pslibdir) {
- xfree(pslibdir);
+ mdvi_free(pslibdir);
pslibdir = NULL;
}
if(psfontdir) {
- xfree(psfontdir);
+ mdvi_free(psfontdir);
psfontdir = NULL;
}
psinitialized = 0;
if(map == NULL)
return NULL;
if(map->fullname)
- return xstrdup(map->fullname);
+ return mdvi_strdup(map->fullname);
/* is it an alias? */
smap = map;
if(psfontdir)
filename = kpse_path_search(psfontdir, smap->mapname, 1);
else if(file_exists(map->mapname))
- filename = xstrdup(map->mapname);
+ filename = mdvi_strdup(map->mapname);
else
filename = NULL;
if(filename)
- map->fullname = xstrdup(filename);
+ map->fullname = mdvi_strdup(filename);
return filename;
}
if(baselen + 4 < 64)
afmfile = &buffer[0];
else
- afmfile = xmalloc(baselen + 5);
+ afmfile = mdvi_malloc(baselen + 5);
strcpy(afmfile, basefile);
strcpy(afmfile + baselen, ".afm");
/* we don't need this anymore */
- xfree(psfont);
+ mdvi_free(psfont);
DEBUG((DBG_FMAP, "(ps) %s: looking for `%s'\n",
fontname, afmfile));
/* lookup the file */
psfont = kpse_path_search(psfontdir, afmfile, 1);
/* don't need this anymore */
if(afmfile != &buffer[0])
- xfree(afmfile);
+ mdvi_free(afmfile);
if(psfont != NULL) {
info = get_font_metrics(fontname, DviFontAFM, psfont);
- xfree(psfont);
+ mdvi_free(psfont);
} else
info = NULL;
if(info == NULL || (!map.extend && !map.slant))
list = xnalloc(char *, n + 1);
fc = (DviFontClass *)font_classes[klass].head;
for(i = 0; i < n; fc = fc->next, i++) {
- list[i] = xstrdup(fc->info.name);
+ list[i] = mdvi_strdup(fc->info.name);
}
list[i] = NULL;
return list;
fc = xalloc(struct _DviFontClass);
fc->links = 0;
fc->id = klass;
- fc->info.name = xstrdup(info->name);
+ fc->info.name = mdvi_strdup(info->name);
fc->info.scalable = info->scalable;
fc->info.load = info->load;
fc->info.getglyph = info->getglyph;
listh_remove(&font_classes[k], LIST(fc));
/* and destroy it */
- xfree(fc->info.name);
- xfree(fc);
+ mdvi_free(fc->info.name);
+ mdvi_free(fc);
return 0;
}
ptr->info.kpse_type, &type);
/* if kpathsea returned a fallback font, reject it */
if(filename && type.source == kpse_glyph_source_fallback) {
- xfree(filename);
+ mdvi_free(filename);
filename = NULL;
} else if(filename)
*h = *v = type.dpi;
DviFont *font;
font = xalloc(DviFont);
- font->fontname = xstrdup(name);
+ font->fontname = mdvi_strdup(name);
SEARCH_INIT(font->search, font->fontname, hdpi, vdpi);
font->filename = mdvi_lookup_font(&font->search);
if(font->filename == NULL) {
/* this answer is final */
- xfree(font->fontname);
- xfree(font);
+ mdvi_free(font->fontname);
+ mdvi_free(font);
return NULL;
}
font->hdpi = font->search.actual_hdpi;
filename = mdvi_lookup_font(&font->search);
if(filename == NULL)
return -1;
- xfree(font->filename);
+ mdvi_free(font->filename);
font->filename = filename;
/* copy the new information */
font->hdpi = font->search.actual_hdpi;
s = read_string(p, op - GF_XXX1 + 1, NULL, 0);
DEBUG((DBG_SPECIAL, "(gf) Character %d: Special \"%s\"\n",
ch->code, s));
- xfree(s);
+ mdvi_free(s);
#else
n = fugetn(p, op - GF_XXX1 + 1);
fseek(p, (long)n, SEEK_CUR);
error(_("%s: File corrupted, or not a GF file\n"), font->fontname);
error:
if(font->chars) {
- xfree(font->chars);
+ mdvi_free(font->chars);
font->chars = NULL;
}
font->loc = font->hic = 0;
if(buck) {
data = buck->data;
- xfree(buck);
+ mdvi_free(buck);
}
return data;
}
hash->nkeys--;
/* destroy the bucket */
ptr = buck->data;
- xfree(buck);
+ mdvi_free(buck);
return ptr;
}
return -1;
if(hash->hash_free)
hash->hash_free(buck->key, buck->data);
- xfree(buck);
+ mdvi_free(buck);
return 0;
}
hash->buckets[i] = buck->next;
if(hash->hash_free)
hash->hash_free(buck->key, buck->data);
- xfree(buck);
+ mdvi_free(buck);
}
}
hash->nkeys = 0;
if(!reuse && hash->buckets) {
- xfree(hash->buckets);
+ mdvi_free(hash->buckets);
hash->buckets = NULL;
hash->nbucks = 0;
} /* otherwise, it is left empty, ready to be reused */
size = 0;
curr = 0;
range = NULL;
- copy = xstrdup(format);
+ copy = mdvi_strdup(format);
done = 0;
lower = 0;
upper = 0;
if(curr == size) {
size += 8;
- range = xrealloc(range, size * sizeof(DviRange));
+ range = mdvi_realloc(range, size * sizeof(DviRange));
}
memcpy(&range[curr++], &one, sizeof(DviRange));
*cp = ch;
if(endptr)
*endptr = (char *)format + (cp - copy);
if(curr && curr < size)
- range = xrealloc(range, curr * sizeof(DviRange));
+ range = mdvi_realloc(range, curr * sizeof(DviRange));
*nitems = curr;
- xfree(copy);
+ mdvi_free(copy);
return range;
}
if(*format != '*') {
range = mdvi_parse_range(format, NULL, &count, &ptr);
if(ptr == format) {
- if(range) xfree(range);
+ if(range) mdvi_free(range);
error(_("invalid page specification `%s'\n"), format);
return NULL;
}
range = mdvi_parse_range(ptr, NULL, &count, &end);
if(end == ptr) {
- if(range) xfree(range);
+ if(range) mdvi_free(range);
range = NULL;
} else
ptr = end;
for(i = 0; i < 11; i++)
if(spec[i]) {
- xfree(spec[i]->ranges);
- xfree(spec[i]);
+ mdvi_free(spec[i]->ranges);
+ mdvi_free(spec[i]);
}
- xfree(spec);
+ mdvi_free(spec);
}
int mdvi_in_range(DviRange *range, int nitems, int value)
}
}
#endif
- if(range) xfree(range);
+ if(range) mdvi_free(range);
}
#else
DviPageSpec *spec;
void mdvi_free_paper_specs(DviPaperSpec *spec)
{
- xfree(spec);
+ mdvi_free(spec);
}
filename = kpse_find_glyph(name, Max(*hdpi, *vdpi),
kpse_pk_format, &type);
if(filename && type.source == kpse_glyph_source_fallback) {
- xfree(filename);
+ mdvi_free(filename);
filename = NULL;
} else if(filename) {
*hdpi = *vdpi = type.dpi;
filename = kpse_find_glyph(name, Max(*hdpi, *vdpi),
kpse_pk_format, &type);
if(filename && type.source == kpse_glyph_source_fallback) {
- xfree(filename);
+ mdvi_free(filename);
filename = NULL;
} else if(filename) {
*hdpi = *vdpi = type.dpi;
if(i < 256)
t = &s[0];
else
- t = xmalloc(i + 1);
+ t = mdvi_malloc(i + 1);
for(n = 0; n < i; n++)
t[n] = fuget1(p);
t[n] = 0;
DEBUG((DBG_SPECIAL, "(pk) %s: Special \"%s\"\n",
font->fontname, t));
if(t != &s[0])
- xfree(t);
+ mdvi_free(t);
#else
i = fugetn(p, flag_byte - PK_X1 + 1);
while(i-- > 0)
badpk:
error(_("%s: File corrupted, or not a PK file\n"), font->fontname);
error:
- xfree(font->chars);
+ mdvi_free(font->chars);
font->chars = NULL;
font->loc = font->hic = 0;
return -1;
file = parse_epsf_special(&box, &special, prefix, arg);
if(file != NULL)
- xfree(special);
+ mdvi_free(special);
/*
* draw the bounding box. Notice that it is in PostScript units,
* so we have to convert it into pixels
sp = find_special_prefix(prefix);
if(sp == NULL) {
sp = xalloc(DviSpecial);
- sp->prefix = xstrdup(prefix);
+ sp->prefix = mdvi_strdup(prefix);
newsp = 1;
} else if(!replace)
return -1;
else {
- xfree(sp->label);
+ mdvi_free(sp->label);
sp->label = NULL;
}
}
if(regex && regcomp(&sp->reg, regex, REG_NOSUB) != 0) {
if(newsp) {
- xfree(sp->prefix);
- xfree(sp);
+ mdvi_free(sp->prefix);
+ mdvi_free(sp);
}
return -1;
}
sp->has_reg = (regex != NULL);
#endif
sp->handler = handler;
- sp->label = xstrdup(label);
+ sp->label = mdvi_strdup(label);
sp->plen = strlen(prefix);
if(newsp)
listh_prepend(&specials, LIST(sp));
sp = find_special_prefix(prefix);
if(sp == NULL)
return -1;
- xfree(sp->prefix);
+ mdvi_free(sp->prefix);
#ifdef WITH_REGEX_SPECIALS
if(sp->has_reg)
regfree(&sp->reg);
#endif
listh_remove(&specials, LIST(sp));
- xfree(sp);
+ mdvi_free(sp);
return 0;
}
for(list = (DviSpecial *)specials.head; (sp = list); ) {
list = sp->next;
- if(sp->prefix) xfree(sp->prefix);
- if(sp->label) xfree(sp->label);
+ if(sp->prefix) mdvi_free(sp->prefix);
+ if(sp->label) mdvi_free(sp->label);
#ifdef WITH_REGEX_SPECIALS
if(sp->has_reg)
regfree(&sp->reg);
#endif
- xfree(sp);
+ mdvi_free(sp);
}
specials.head = NULL;
specials.tail = NULL;
DEBUG((DBG_TYPE1, "(t1) %s: found `%s' (cached)\n",
name, info.fullfile));
/* this is a cached lookup */
- return xstrdup(info.fullfile);
+ return mdvi_strdup(info.fullfile);
}
/* no file associated to this font? */
/* get the `base' name */
if(ext) {
- newname = xstrdup(name);
+ newname = mdvi_strdup(name);
newname[ext - info.fontfile - 1] = 0;
} else
newname = (char *)name; /* we don't modify this */
/* we don't need this anymore */
if(newname != name)
- xfree(newname);
+ mdvi_free(newname);
if(filename == NULL) {
DEBUG((DBG_TYPE1, "(t1) %s: not found\n", name));
return NULL;
i = info->tfminfo->hic - info->tfminfo->loc + 1;
if(i != font->hic - font->loc + 1) {
/* reset to optimal size */
- font->chars = xrealloc(font->chars, i * sizeof(DviFontChar));
+ font->chars = mdvi_realloc(font->chars, i * sizeof(DviFontChar));
}
/* get the scaled characters metrics */
/* first destroy the private data */
t1_font_remove(info);
/* now reset all chars -- this is the important part */
- xfree(font->chars);
+ mdvi_free(font->chars);
font->chars = NULL;
font->loc = font->hic = 0;
return -1;
if(info->tfminfo)
free_font_metrics(info->tfminfo);
- /*xfree(info->fontname);*/
- xfree(info);
+ /*mdvi_free(info->fontname);*/
+ mdvi_free(info);
}
static void t1_free_data(DviFont *font)
n = info->hic - info->loc + 1;
if(n != FONT_GLYPH_COUNT(font)) {
- font->chars = xrealloc(font->chars,
+ font->chars = mdvi_realloc(font->chars,
n * sizeof(DviFontChar));
}
font->loc = info->loc;
info->design = 0xa00000; /* fake -- 10pt */
info->checksum = 0; /* no checksum */
info->type = DviFontAFM;
- xstrncpy(info->coding, fi->gfi->encodingScheme, 63);
- xstrncpy(info->family, fi->gfi->familyName, 63);
+ mdvi_strncpy(info->coding, fi->gfi->encodingScheme, 63);
+ mdvi_strncpy(info->family, fi->gfi->familyName, 63);
/* now get the data */
for(cm = fi->cmi; cm < fi->cmi + fi->numOfChars; cm++) {
memmove(&info->chars[0],
&info->chars[info->loc],
(info->hic - info->loc + 1) * sizeof(TFMChar));
- info->chars = xrealloc(info->chars,
+ info->chars = mdvi_realloc(info->chars,
(info->hic - info->loc + 1) * sizeof(TFMChar));
}
if(size != st.st_size)
warning(_("Warning: TFM file `%s' has suspicious size\n"),
filename);
- tfm = (Uchar *)xmalloc(size);
+ tfm = (Uchar *)mdvi_malloc(size);
if(fread(tfm, st.st_size, 1, in) != 1)
goto error;
/* we don't need this anymore */
}
/* free everything */
- xfree(tfm);
+ mdvi_free(tfm);
return 0;
bad_tfm:
error(_("%s: File corrupted, or not a TFM file\n"), filename);
error:
- if(tfm) xfree(tfm);
+ if(tfm) mdvi_free(tfm);
if(in) fclose(in);
return -1;
}
tfm = xnalloc(Int32, size);
/* read them in one sweep */
if(fread(tfm, 4, size, in) != size) {
- xfree(tfm);
+ mdvi_free(tfm);
goto bad_tfm;
}
}
/* NOW we're done */
- xfree(tfm);
+ mdvi_free(tfm);
return 0;
bad_tfm:
- if(tfm) xfree(tfm);
+ if(tfm) mdvi_free(tfm);
return -1;
}
size = 2*(ec - bc + 1) + nw + nh + nd;
tfm = xnalloc(Int32, size * sizeof(Int32));
if(fread(tfm, 4, size, in) != size) {
- xfree(tfm);
+ mdvi_free(tfm);
goto bad_tfm;
}
/* byte-swap all the tables at once */
depths = cb;
if(widths[0] || heights[0] || depths[0]) {
- xfree(tfm);
+ mdvi_free(tfm);
goto bad_tfm;
}
info->chars[i-bc].depth = depths[ndx];
}
- xfree(tfm);
+ mdvi_free(tfm);
return 0;
bad_tfm:
break;
}
if(file != filename)
- xfree(file);
+ mdvi_free(file);
if(status < 0) {
- xfree(tfm);
+ mdvi_free(tfm);
return NULL;
}
- tfm->short_name = xstrdup(short_name);
+ tfm->short_name = mdvi_strdup(short_name);
/* add it to the pool */
if(tfmpool.count == 0)
DEBUG((DBG_FONTS, "(mt) removing unused TFM data for `%s'\n", tfm->short_name));
listh_remove(&tfmpool, LIST(tfm));
- xfree(tfm->short_name);
- xfree(tfm->tfminfo.chars);
- xfree(tfm);
+ mdvi_free(tfm->short_name);
+ mdvi_free(tfm->tfminfo.chars);
+ mdvi_free(tfm);
}
void flush_font_metrics(void)
for(; (ptr = (TFMPool *)tfmpool.head); ) {
tfmpool.head = LIST(ptr->next);
- xfree(ptr->short_name);
- xfree(ptr->tfminfo.chars);
- xfree(ptr);
+ mdvi_free(ptr->short_name);
+ mdvi_free(ptr->tfminfo.chars);
+ mdvi_free(ptr);
}
mdvi_hash_reset(&tfmhash, 0);
}
tt_error:
tt_font_remove(info);
- xfree(font->chars);
+ mdvi_free(font->chars);
font->chars = NULL;
font->loc = font->hic = 0;
return -1;
raster.cols = ROUND(w, 8);
raster.size = h * raster.cols;
raster.flow = TT_Flow_Down;
- raster.bitmap = xcalloc(h, raster.cols);
+ raster.bitmap = mdvi_calloc(h, raster.cols);
TT_Translate_Outline(&outline, -bbox.xMin, -bbox.yMin);
TT_Get_Outline_Bitmap(tt_handle, &outline, &raster);
glyph->data = bitmap_convert_msb8(raster.bitmap, w, h);
TT_Done_Outline(&outline);
- xfree(raster.bitmap);
+ mdvi_free(raster.bitmap);
return 0;
tt_error:
if(info->tfminfo)
free_font_metrics(info->tfminfo);
if(info->fmfname)
- xfree(info->fmfname);
- xfree(info);
+ mdvi_free(info->fmfname);
+ mdvi_free(info);
}
static void tt_free_data(DviFont *font)
#endif
}
-void *xmalloc(size_t nelems)
+void *mdvi_malloc(size_t nelems)
{
void *ptr = malloc(nelems);
return ptr;
}
-void *xrealloc(void *data, size_t newsize)
+void *mdvi_realloc(void *data, size_t newsize)
{
void *ptr;
return ptr;
}
-void *xcalloc(size_t nmemb, size_t size)
+void *mdvi_calloc(size_t nmemb, size_t size)
{
void *ptr;
return ptr;
}
-void xfree(void *ptr)
+void mdvi_free(void *ptr)
{
if(ptr == NULL)
crash(_("attempted to free NULL pointer\n"));
free(ptr);
}
-char *xstrdup(const char *string)
+char *mdvi_strdup(const char *string)
{
int length;
char *ptr;
length = strlen(string) + 1;
- ptr = (char *)xmalloc(length);
+ ptr = (char *)mdvi_malloc(length);
memcpy(ptr, string, length);
return ptr;
}
/* `to' should have room for length+1 bytes */
-char *xstrncpy(char *to, const char *from, size_t length)
+char *mdvi_strncpy(char *to, const char *from, size_t length)
{
strncpy(to, from, length);
to[length] = '\0';
return to;
}
-char *xstrndup(const char *string, size_t length)
+char *mdvi_strndup(const char *string, size_t length)
{
int n;
char *ptr;
n = strlen(string);
if(n > length)
n = length;
- ptr = (char *)xmalloc(n + 1);
+ ptr = (char *)mdvi_malloc(n + 1);
memcpy(ptr, string, n);
return ptr;
}
-void *xmemdup(const void *data, size_t length)
+void *mdvi_memdup(const void *data, size_t length)
{
- void *ptr = xmalloc(length);
+ void *ptr = mdvi_malloc(length);
memcpy(ptr, data, length);
return ptr;
if(m == 0)
m = strlen(src);
if(n + m >= *size) {
- dest = xrealloc(dest, n + m + 1);
+ dest = mdvi_realloc(dest, n + m + 1);
*size = n + m + 1;
}
memcpy(dest + n, src, m);
if(len) {
if(dstr->length + len >= dstr->size) {
dstr->size = pow2(dstr->length + len + 1);
- dstr->data = xrealloc(dstr->data, dstr->size);
+ dstr->data = mdvi_realloc(dstr->data, dstr->size);
}
memcpy(dstr->data + dstr->length, string, len);
dstr->length += len;
} else if(dstr->size == 0) {
ASSERT(dstr->data == NULL);
dstr->size = 8;
- dstr->data = xmalloc(8);
+ dstr->data = mdvi_malloc(8);
dstr->data[0] = 0;
}
if(len) {
if(dstr->length + len >= dstr->size) {
dstr->size = pow2(dstr->length + len + 1);
- dstr->data = xrealloc(dstr->data, dstr->size);
+ dstr->data = mdvi_realloc(dstr->data, dstr->size);
}
/* make room */
memmove(dstr->data + pos, dstr->data + pos + len, len);
len = strlen(string);
if(len) {
dstr->size = pow2(len + 1);
- dstr->data = xmalloc(dstr->size * len);
+ dstr->data = mdvi_malloc(dstr->size * len);
memcpy(dstr->data, string, len);
} else
dstring_init(dstr);
void dstring_reset(Dstring *dstr)
{
if(dstr->data)
- xfree(dstr->data);
+ mdvi_free(dstr->data);
dstring_init(dstr);
}
hdpi = FROUND(params->mag * params->dpi * scale / design);
vdpi = FROUND(params->mag * params->vdpi * scale / design);
n = fuget1(p) + fuget1(p);
- name = xmalloc(n + 1);
+ name = mdvi_malloc(n + 1);
fread(name, 1, n, p);
name[n] = 0;
DEBUG((DBG_FONTS, "(vf) %s: defined font `%s' at %.1fpt (%dx%d dpi)\n",
font->fontname, name);
goto error;
}
- xfree(name);
+ mdvi_free(name);
if(last == NULL)
font->subfonts = last = ref;
else
error(_("%s: File corrupted, or not a VF file.\n"), font->fontname);
error:
if(font->chars)
- xfree(font->chars);
+ mdvi_free(font->chars);
if(macros)
- xfree(macros);
+ mdvi_free(macros);
return -1;
}
static void vf_free_macros(DviFont *font)
{
- xfree(font->private);
+ mdvi_free(font->private);
}
"name", _("Evince"),
"version", VERSION,
"copyright",
- _("\xc2\xa9 1996-2004 The Evince authors"),
+ _("\xc2\xa9 1996-2005 The Evince authors"),
"license", license_trans,
"website", "http://www.gnome.org/projects/evince",
"comments", comments,