|
Revision 2110, 1.6 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_MetaName * |
|---|
| 25 |
swish_init_metaname( |
|---|
| 26 |
xmlChar *name |
|---|
| 27 |
) |
|---|
| 28 |
{ |
|---|
| 29 |
swish_MetaName *m; |
|---|
| 30 |
m = swish_xmalloc(sizeof(swish_MetaName)); |
|---|
| 31 |
m->ref_cnt = 0; |
|---|
| 32 |
m->id = -1; |
|---|
| 33 |
m->name = name; |
|---|
| 34 |
m->bias = 0; |
|---|
| 35 |
m->alias_for = NULL; |
|---|
| 36 |
return m; |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
void |
|---|
| 40 |
swish_debug_metaname( |
|---|
| 41 |
swish_MetaName *m |
|---|
| 42 |
) |
|---|
| 43 |
{ |
|---|
| 44 |
SWISH_DEBUG_MSG("\n\ |
|---|
| 45 |
m->ref_cnt = %d\n\ |
|---|
| 46 |
m->id = %d\n\ |
|---|
| 47 |
m->name = %s\n\ |
|---|
| 48 |
m->bias = %d\n\ |
|---|
| 49 |
m->alias_for = %s\n\ |
|---|
| 50 |
", m->ref_cnt, m->id, m->name, m->bias, m->alias_for); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
void |
|---|
| 54 |
swish_free_metaname( |
|---|
| 55 |
swish_MetaName *m |
|---|
| 56 |
) |
|---|
| 57 |
{ |
|---|
| 58 |
if (m->ref_cnt != 0) { |
|---|
| 59 |
SWISH_WARN("MetaName ref_cnt != 0: %d", m->ref_cnt); |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
if (m->name != NULL) { |
|---|
| 63 |
swish_xfree(m->name); |
|---|
| 64 |
} |
|---|
| 65 |
if (m->alias_for != NULL) { |
|---|
| 66 |
swish_xfree(m->alias_for); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
swish_xfree(m); |
|---|
| 70 |
} |
|---|