|
Revision 2110, 1.9 kB
(checked in by karpet, 8 months ago)
|
Refactor duplicate id checks to use hash instead of array. Fixes bug with merging configs. Default ->id is now -1 (invalid value)
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
#include "libswish3.h" |
|---|
| 21 |
|
|---|
| 22 |
extern int SWISH_DEBUG; |
|---|
| 23 |
|
|---|
| 24 |
swish_Property * |
|---|
| 25 |
swish_init_property( |
|---|
| 26 |
xmlChar *name |
|---|
| 27 |
) |
|---|
| 28 |
{ |
|---|
| 29 |
swish_Property *p; |
|---|
| 30 |
p = swish_xmalloc(sizeof(swish_Property)); |
|---|
| 31 |
p->ref_cnt = 0; |
|---|
| 32 |
p->id = -1; |
|---|
| 33 |
p->name = name; |
|---|
| 34 |
p->ignore_case = 1; |
|---|
| 35 |
p->type = SWISH_PROP_STRING; |
|---|
| 36 |
p->verbatim = 0; |
|---|
| 37 |
p->alias_for = NULL; |
|---|
| 38 |
p->max = 0; |
|---|
| 39 |
p->sort = 0; |
|---|
| 40 |
return p; |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
void |
|---|
| 44 |
swish_debug_property( |
|---|
| 45 |
swish_Property *p |
|---|
| 46 |
) |
|---|
| 47 |
{ |
|---|
| 48 |
SWISH_DEBUG_MSG("\n\ |
|---|
| 49 |
p->ref_cnt = %d\n\ |
|---|
| 50 |
p->id = %d\n\ |
|---|
| 51 |
p->name = %s\n\ |
|---|
| 52 |
p->ignore_case = %d\n\ |
|---|
| 53 |
p->type = %d\n\ |
|---|
| 54 |
p->verbatim = %d\n\ |
|---|
| 55 |
p->alias_for = %s\n\ |
|---|
| 56 |
p->max = %d\n\ |
|---|
| 57 |
p->sort = %d\n\ |
|---|
| 58 |
", p->ref_cnt, p->id, p->name, p->ignore_case, p->type, p->verbatim, p->alias_for, p->max, p->sort); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
void |
|---|
| 62 |
swish_free_property( |
|---|
| 63 |
swish_Property *p |
|---|
| 64 |
) |
|---|
| 65 |
{ |
|---|
| 66 |
if (p->ref_cnt != 0) { |
|---|
| 67 |
SWISH_WARN("Property ref_cnt != 0: %d", p->ref_cnt); |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
if (p->name != NULL) { |
|---|
| 71 |
swish_xfree(p->name); |
|---|
| 72 |
} |
|---|
| 73 |
if (p->alias_for != NULL) { |
|---|
| 74 |
swish_xfree(p->alias_for); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
swish_xfree(p); |
|---|
| 78 |
} |
|---|