Back to index

tetex-bin  3.0
Functions | Variables
avlstuff.c File Reference
#include "ptexlib.h"
#include <kpathsea/c-vararg.h>
#include <kpathsea/c-proto.h>
#include "avl.h"

Go to the source code of this file.

Functions

voidavl_xmalloc (struct libavl_allocator *allocator, size_t size)
void avl_xfree (struct libavl_allocator *allocator, void *block)
int compare_info (const void *pa, const void *pb, void *param)
void avlputobj (integer objptr, integer t)
integer avlfindobj (integer t, integer i, integer byname)

Variables

static const char perforce_id [] = "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/avlstuff.c#5 $"
static struct avl_tablePdfObjTree [pdfobjtypemax+1]

Function Documentation

void avl_xfree ( struct libavl_allocator allocator,
void block 
)

Definition at line 45 of file avlstuff.c.

{
    assert(allocator != NULL && block != NULL);
    xfree(block);
}
void* avl_xmalloc ( struct libavl_allocator allocator,
size_t  size 
)

Definition at line 39 of file avlstuff.c.

{
    assert(allocator != NULL && size > 0);
    return xmalloc(size);
}

Here is the call graph for this function:

integer avlfindobj ( integer  t,
integer  i,
integer  byname 
)

Definition at line 113 of file avlstuff.c.

{
    static objentry *p;
    static objentry tmp;

    if (byname > 0)
        tmp.int0 = -i;
    else
        tmp.int0 = i;
    if (PdfObjTree[t] == NULL)
        return 0;
    p = (objentry *) avl_find(PdfObjTree[t], &tmp);
    if (p == NULL)
        return 0;
    else
        return (int) (p - (objentry *) objtab);
}

Here is the call graph for this function:

void avlputobj ( integer  objptr,
integer  t 
)

Definition at line 96 of file avlstuff.c.

{
    static void **pp;

    if (PdfObjTree[t] == NULL) {
        PdfObjTree[t] = avl_create(compare_info, NULL, &avl_xallocator);
        if (PdfObjTree[t] == NULL)
            pdftex_fail("avlstuff.c: avl_create() PdfObjTree failed");
    }
    pp = avl_probe(PdfObjTree[t], &(objtab[objptr]));
    if (pp == NULL)
        pdftex_fail("avlstuff.c: avl_probe() out of memory in insertion");
}

Here is the call graph for this function:

int compare_info ( const void pa,
const void pb,
void param 
)

Definition at line 59 of file avlstuff.c.

{
    integer a, b;
    int as, ae, bs, be, al, bl;

    a = ((const objentry *) pa)->int0;
    b = ((const objentry *) pb)->int0;
    if (a < 0 && b < 0) {        /* string comparison */
        as = strstart[-a];
        ae = strstart[-a + 1];        /* start of next string in pool */
        bs = strstart[-b];
        be = strstart[-b + 1];
        al = ae - as;
        bl = be - bs;
        if (al < bl)                /* compare first by string length */
            return -1;
        else if (al > bl)
            return 1;
        else
            for (; as < ae; as++, bs++) {
                if (strpool[as] < strpool[bs])
                    return -1;
                if (strpool[as] > strpool[bs])
                    return 1;
            }
        return 0;
    } else {                        /* integer comparison */
        if (a < b)
            return -1;
        else if (a > b)
            return 1;
        else
            return 0;
    }
}

Here is the caller graph for this function:


Variable Documentation

struct avl_table* PdfObjTree[pdfobjtypemax+1] [static]
Initial value:
    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }

Definition at line 33 of file avlstuff.c.

const char perforce_id[] = "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/avlstuff.c#5 $" [static]

Definition at line 28 of file avlstuff.c.