3 WvAttrs::WvAttrs() : attrlist(NULL), attrlen(0)
7 WvAttrs::WvAttrs(
const WvAttrs ©) : attrlist(NULL), attrlen(copy.attrlen)
10 attrlist = (
char *)malloc((copy.attrlen + 1) *
sizeof(char));
11 memcpy(attrlist, copy.attrlist, copy.attrlen + 1);
20 char *WvAttrs::_get(WvStringParm name)
const
25 const char *curpos = attrlist;
28 const char *
const valoffset = curpos + strlen(curpos) + 1;
29 if (!strcmp(curpos, name.cstr()))
30 return (
char *)valoffset;
32 curpos = valoffset + strlen(valoffset) + 1;
38 void WvAttrs::set(WvStringParm name, WvStringParm value)
43 const int namelen = name.len();
44 char *exists = _get(name);
48 const int toremove = namelen + strlen(exists) + 2;
49 exists -= namelen + 1;
52 const int endpart = attrlen - (exists - attrlist) - toremove + 1;
53 memmove(exists, exists + toremove, endpart);
55 attrlist = (
char *)realloc(attrlist, (attrlen + 1)
62 const unsigned int totallen = namelen + value.len() + 2;
63 attrlist = (
char *)realloc(attrlist, (attrlen + totallen + 1)*
sizeof(char));
65 char *
const beginloc = attrlist + attrlen;
66 strcpy(beginloc, name.cstr());
67 strcpy(beginloc + namelen + 1, value.cstr());
70 attrlist[attrlen] = 0;