diff options
author | Nvinside@gmail.com <Nvinside@gmail.com@eced67a3-f377-a0ae-92ae-d6de1850b05a> | 2011-10-29 21:17:12 +0000 |
---|---|---|
committer | Nvinside@gmail.com <Nvinside@gmail.com@eced67a3-f377-a0ae-92ae-d6de1850b05a> | 2011-10-29 21:17:12 +0000 |
commit | 7deb21a37c0f6ba6339ec0f8b7fb83fa397faf58 (patch) | |
tree | 62cb0944e1a43dfacbdbb3f7e3b32a9643ef2db4 /ekhtml | |
parent | e91fa6de03f2351bc128a015978a657409d351b4 (diff) |
* Fixed memory leak when destroying ekhtml instance
* Allow comma, semicolon, and pipe as valid characters in unquoted attribute values
* Calculation moves
* Provide information about what type of quotation was used for attribute values
git-svn-id: http://mirotr.googlecode.com/svn/trunk@62 eced67a3-f377-a0ae-92ae-d6de1850b05a
Diffstat (limited to 'ekhtml')
-rw-r--r-- | ekhtml/include/ekhtml.h | 9 | ||||
-rw-r--r-- | ekhtml/include/ekhtml_private.h | 2 | ||||
-rw-r--r-- | ekhtml/include/hash.h | 31 |
3 files changed, 33 insertions, 9 deletions
diff --git a/ekhtml/include/ekhtml.h b/ekhtml/include/ekhtml.h index 1bed8ea..ba4b196 100644 --- a/ekhtml/include/ekhtml.h +++ b/ekhtml/include/ekhtml.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Jon Travis + * Copyright (c) 2002-2004, Jon Travis * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,14 +57,15 @@ typedef struct ekhtml_string_t { * When ekhtml parses tags containing key/value attributes, it will pass * this structure representing those values into the callbacks. Note, for * speed reasons, things such as the 'name' and 'value' fields are not - * terminated with '\0', and therefore have an associated length - * field (namelen, vallen). + * terminated with '\0', the length is in name->len, and val->len */ typedef struct ekhtml_attr_t { ekhtml_string_t name; /**< Name of the attribute */ ekhtml_string_t val; /**< Value of the attribute */ - unsigned int isBoolean; /**< True of the attribute is boolean */ + unsigned int isBoolean; /**< True if the attribute is boolean */ + char quoteChar; /**< The character used to quote 'val'. + If no quoting was used, '\0' */ struct ekhtml_attr_t *next; /**< Pointer to next attribute in the list */ } ekhtml_attr_t; diff --git a/ekhtml/include/ekhtml_private.h b/ekhtml/include/ekhtml_private.h index 47d3128..ea0a99d 100644 --- a/ekhtml/include/ekhtml_private.h +++ b/ekhtml/include/ekhtml_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Jon Travis + * Copyright (c) 2002-2004, Jon Travis * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/ekhtml/include/hash.h b/ekhtml/include/hash.h index ddb3869..5b6333e 100644 --- a/ekhtml/include/hash.h +++ b/ekhtml/include/hash.h @@ -14,8 +14,6 @@ * into proprietary software; there is no requirement for such software to * contain a copyright notice related to this source. * - * $Id: hash.h,v 1.1 2002/09/17 02:49:36 jick Exp $ - * $Name: EKHTML_RELEASE_0_3_2 $ */ #ifndef HASH_H @@ -40,8 +38,6 @@ typedef unsigned long hashcount_t; typedef unsigned long hash_val_t; #define HASH_VAL_T_MAX ULONG_MAX -extern int hash_val_t_bit; - #ifndef HASH_VAL_T_BIT #define HASH_VAL_T_BIT ((int) hash_val_t_bit) #endif @@ -233,6 +229,33 @@ extern void hnode_destroy(hnode_t *); #define hnode_put(N, V) ((N)->hash_data = (V)) #endif +/* + * Compute the number of bits in the hash_val_t type. We know that hash_val_t + * is an unsigned integral type. Thus the highest value it can hold is a + * Mersenne number (power of two, less one). We initialize a hash_val_t + * object with this value and then shift bits out one by one while counting. + * Notes: + * 1. HASH_VAL_T_MAX is a Mersenne number---one that is one less than a power + * of two. This means that its binary representation consists of all one + * bits, and hence ``val'' is initialized to all one bits. + * 2. While bits remain in val, we increment the bit count and shift it to the + * right, replacing the topmost bit by zero. + */ + +static int compute_bits(void) +{ + hash_val_t val = HASH_VAL_T_MAX; /* 1 */ + int bits = 0; + + while (val) { /* 2 */ + bits++; + val >>= 1; + } + + return bits; +} + + #ifdef __cplusplus } #endif |