forked from github/server
coverity scan does not understand get_or_create_equipment?
This commit is contained in:
parent
0d0fb49381
commit
8e0bdbe428
|
@ -214,19 +214,26 @@ equipment *get_equipment(const char *eqname)
|
||||||
return eq;
|
return eq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
equipment *create_equipment(const char *eqname)
|
||||||
|
{
|
||||||
|
equipment *eq;
|
||||||
|
size_t len;
|
||||||
|
char data[64];
|
||||||
|
|
||||||
|
eq = (equipment *)calloc(1, sizeof(equipment));
|
||||||
|
eq->name = strdup(eqname);
|
||||||
|
|
||||||
|
len = cb_new_kv(eqname, strlen(eqname), &eq, sizeof(eq), data);
|
||||||
|
assert(len <= sizeof(data));
|
||||||
|
cb_insert(&cb_equipments, data, len);
|
||||||
|
return eq;
|
||||||
|
}
|
||||||
|
|
||||||
equipment *get_or_create_equipment(const char *eqname)
|
equipment *get_or_create_equipment(const char *eqname)
|
||||||
{
|
{
|
||||||
equipment *eq = get_equipment(eqname);
|
equipment *eq = get_equipment(eqname);
|
||||||
if (!eq) {
|
if (!eq) {
|
||||||
size_t len;
|
return create_equipment(eqname);
|
||||||
char data[64];
|
|
||||||
|
|
||||||
eq = (equipment *)calloc(1, sizeof(equipment));
|
|
||||||
eq->name = strdup(eqname);
|
|
||||||
|
|
||||||
len = cb_new_kv(eqname, strlen(eqname), &eq, sizeof(eq), data);
|
|
||||||
assert(len <= sizeof(data));
|
|
||||||
cb_insert(&cb_equipments, data, len);
|
|
||||||
}
|
}
|
||||||
return eq;
|
return eq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ extern "C" {
|
||||||
|
|
||||||
struct equipment *get_or_create_equipment(const char *eqname);
|
struct equipment *get_or_create_equipment(const char *eqname);
|
||||||
struct equipment *get_equipment(const char *eqname);
|
struct equipment *get_equipment(const char *eqname);
|
||||||
|
struct equipment *create_equipment(const char *eqname);
|
||||||
|
|
||||||
void equipment_setitem(struct equipment *eq,
|
void equipment_setitem(struct equipment *eq,
|
||||||
const struct item_type *itype, const char *value);
|
const struct item_type *itype, const char *value);
|
||||||
|
|
|
@ -46,10 +46,10 @@ extern "C" {
|
||||||
int level;
|
int level;
|
||||||
} msglevel;
|
} msglevel;
|
||||||
|
|
||||||
extern struct message *msg_message(const char *name, const char *sig, ...);
|
struct message *msg_message(const char *name, const char *sig, ...);
|
||||||
extern struct message *msg_feedback(const struct unit *, struct order *cmd,
|
struct message *msg_feedback(const struct unit *, struct order *cmd,
|
||||||
const char *name, const char *sig, ...);
|
const char *name, const char *sig, ...);
|
||||||
extern struct message *add_message(struct message_list **pm,
|
struct message *add_message(struct message_list **pm,
|
||||||
struct message *m);
|
struct message *m);
|
||||||
void addmessage(struct region *r, struct faction *f, const char *s,
|
void addmessage(struct region *r, struct faction *f, const char *s,
|
||||||
msg_t mtype, int level);
|
msg_t mtype, int level);
|
||||||
|
|
|
@ -1069,9 +1069,13 @@ static int parse_equipment(xmlDocPtr doc)
|
||||||
xmlChar *propName = xmlGetProp(node, BAD_CAST "name");
|
xmlChar *propName = xmlGetProp(node, BAD_CAST "name");
|
||||||
|
|
||||||
if (propName != NULL) {
|
if (propName != NULL) {
|
||||||
equipment *eq = get_or_create_equipment((const char *)propName);
|
equipment *eq = get_equipment((const char *)propName);
|
||||||
xmlXPathObjectPtr xpathResult;
|
xmlXPathObjectPtr xpathResult;
|
||||||
|
|
||||||
|
if (!eq) {
|
||||||
|
eq = create_equipment((const char *)propName);
|
||||||
|
}
|
||||||
|
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
|
||||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "callback", xpath);
|
xpathResult = xmlXPathEvalExpression(BAD_CAST "callback", xpath);
|
||||||
|
|
Loading…
Reference in New Issue