/[radius]/radius/lib/avl.c
ViewVC logotype

Diff of /radius/lib/avl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by gray, Fri May 30 10:36:06 2003 UTC revision 1.8 by gray, Tue Jun 3 14:17:27 2003 UTC
# Line 43  Line 43 
43  VALUE_PAIR *  VALUE_PAIR *
44  avp_alloc()  avp_alloc()
45  {  {
46          return mem_alloc(sizeof(VALUE_PAIR));          return emalloc(sizeof(VALUE_PAIR));
47  }  }
48    
49  void  void
# Line 52  avp_free(VALUE_PAIR *p) Line 52  avp_free(VALUE_PAIR *p)
52          if (!p)          if (!p)
53                  return;                  return;
54          if (p->type == TYPE_STRING || p->eval)          if (p->type == TYPE_STRING || p->eval)
55                  string_free(p->avp_strvalue);                  efree(p->avp_strvalue);
56          mem_free(p);          efree(p);
57  }  }
58    
59  /* A/V pair functions */  /* A/V pair functions */
# Line 66  avp_dup(VALUE_PAIR *vp) Line 66  avp_dup(VALUE_PAIR *vp)
66    
67          memcpy(ret, vp, sizeof(VALUE_PAIR));          memcpy(ret, vp, sizeof(VALUE_PAIR));
68          ret->next = NULL;          ret->next = NULL;
69          if (ret->type == TYPE_STRING || ret->eval)          if (ret->type == TYPE_STRING || ret->eval) {
70                  ret->avp_strvalue = string_dup(vp->avp_strvalue);                  ret->avp_strlength = vp->avp_strlength;
71                    ret->avp_strvalue = emalloc(ret->avp_strlength+1);
72                    memcpy(ret->avp_strvalue, vp->avp_strvalue,
73                           ret->avp_strlength);
74                    ret->avp_strvalue[ret->avp_strlength] = 0;
75            }
76          return ret;          return ret;
77  }  }
78    
# Line 91  avp_create(int attr, int length, char *s Line 96  avp_create(int attr, int length, char *s
96          pair->prop = dict->prop;          pair->prop = dict->prop;
97          if (strval) {          if (strval) {
98                  pair->avp_strlength = length;                  pair->avp_strlength = length;
99                  pair->avp_strvalue = string_create(strval);                  pair->avp_strvalue = estrdup(strval);
100          } else          } else
101                  pair->avp_lvalue = lval;                  pair->avp_lvalue = lval;
102    
# Line 388  avl_dup(VALUE_PAIR *from) Line 393  avl_dup(VALUE_PAIR *from)
393          for ( ; from; from = from->next) {          for ( ; from; from = from->next) {
394                  temp = avp_alloc();                  temp = avp_alloc();
395                  memcpy(temp, from, sizeof(VALUE_PAIR));                  memcpy(temp, from, sizeof(VALUE_PAIR));
396                  if (temp->type == TYPE_STRING || temp->eval)                  if (temp->type == TYPE_STRING || temp->eval) {
397                          temp->avp_strvalue = string_dup(temp->avp_strvalue);                          char *p = emalloc(temp->avp_strlength+1);
398                            memcpy(p, temp->avp_strvalue, temp->avp_strlength);
399                            p[temp->avp_strlength] = 0;
400                            temp->avp_strvalue = p;
401                    }
402                  temp->next = NULL;                  temp->next = NULL;
403                  if (last)                  if (last)
404                          last->next = temp;                          last->next = temp;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26