~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to cdt/dtrenew.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
#include        "dthdr.h"
 
11
 
 
12
#ifdef DMALLOC
 
13
#include "dmalloc.h"
 
14
#endif
 
15
 
 
16
/*      Renew the object at the current finger.
 
17
**
 
18
**      Written by Kiem-Phong Vo (5/25/96)
 
19
*/
 
20
 
 
21
#if __STD_C
 
22
Void_t* dtrenew(Dt_t* dt, reg Void_t* obj)
 
23
#else
 
24
Void_t* dtrenew(dt, obj)
 
25
Dt_t*           dt;
 
26
reg Void_t*     obj;
 
27
#endif
 
28
{
 
29
        reg Void_t*     key;
 
30
        reg Dtlink_t    *e, *t, **s;
 
31
        reg Dtdisc_t*   disc = dt->disc;
 
32
 
 
33
        UNFLATTEN(dt);
 
34
 
 
35
        if(!(e = dt->data->here) || OBJ(e,disc->link) != obj)
 
36
                return NIL(Void_t*);
 
37
 
 
38
        if(dt->data->type&(DT_STACK|DT_QUEUE|DT_LIST))
 
39
                return obj;
 
40
        else if(dt->data->type&(DT_OSET|DT_OBAG) )
 
41
        {       if(!e->right )  /* make left child the new root */
 
42
                        dt->data->here = e->left;
 
43
                else            /* make right child the new root */
 
44
                {       dt->data->here = e->right;
 
45
 
 
46
                        /* merge left subtree to right subtree */
 
47
                        if(e->left)
 
48
                        {       for(t = e->right; t->left; t = t->left)
 
49
                                        ;
 
50
                                t->left = e->left;
 
51
                        }
 
52
                }
 
53
        }
 
54
        else /*if(dt->data->type&(DT_SET|DT_BAG))*/
 
55
        {       s = dt->data->htab + HINDEX(dt->data->ntab,e->hash);
 
56
                if((t = *s) == e)
 
57
                        *s = e->right;
 
58
                else
 
59
                {       for(; t->right != e; t = t->right)
 
60
                                ;
 
61
                        t->right = e->right;
 
62
                }
 
63
                key = KEY(obj,disc->key,disc->size);
 
64
                e->hash = HASH(dt,key,disc,disc->size);
 
65
                dt->data->here = NIL(Dtlink_t*);
 
66
        }
 
67
 
 
68
        dt->data->size -= 1;
 
69
        return (*dt->meth->searchf)(dt,(Void_t*)e,DT_RENEW) ? obj : NIL(Void_t*);
 
70
}