forked from github/server
eliminate strdup
The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
This commit is contained in:
parent
4a5d2d8de9
commit
30b3911637
|
@ -185,7 +185,7 @@ struct attrib *object_create(const char *name, object_type type, variant value)
|
|||
{
|
||||
attrib *a = a_new(&at_object);
|
||||
object_data *data = (object_data *) a->data.v;
|
||||
data->name = strdup(name);
|
||||
data->name = _strdup(name);
|
||||
|
||||
object_set(a, type, value);
|
||||
return a;
|
||||
|
@ -200,7 +200,7 @@ void object_set(attrib * a, object_type type, variant value)
|
|||
data->type = type;
|
||||
switch (type) {
|
||||
case TSTRING:
|
||||
data->data.str = value.v ? strdup(value.v) : NULL;
|
||||
data->data.str = value.v ? _strdup(value.v) : NULL;
|
||||
break;
|
||||
case TINTEGER:
|
||||
data->data.i = value.i;
|
||||
|
|
|
@ -44,13 +44,13 @@ void set_racename(attrib ** palist, const char *name)
|
|||
attrib *a = a_find(*palist, &at_racename);
|
||||
if (!a && name) {
|
||||
a = a_add(palist, a_new(&at_racename));
|
||||
a->data.v = strdup(name);
|
||||
a->data.v = _strdup(name);
|
||||
} else if (a && !name) {
|
||||
a_remove(palist, a);
|
||||
} else if (a) {
|
||||
if (strcmp(a->data.v, name) != 0) {
|
||||
free(a->data.v);
|
||||
a->data.v = strdup(name);
|
||||
a->data.v = _strdup(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ void set_prefix(attrib ** ap, const char *str)
|
|||
free(a->data.v);
|
||||
}
|
||||
assert(a->type == &at_raceprefix);
|
||||
a->data.v = strdup(str);
|
||||
a->data.v = _strdup(str);
|
||||
}
|
||||
|
||||
const char *get_prefix(const attrib * a)
|
||||
|
@ -52,7 +52,7 @@ const char *get_prefix(const attrib * a)
|
|||
str = (char *)a->data.v;
|
||||
/* conversion of old prefixes */
|
||||
if (strncmp(str, "prefix_", 7) == 0) {
|
||||
((attrib *) a)->data.v = strdup(str + 7);
|
||||
((attrib *) a)->data.v = _strdup(str + 7);
|
||||
free(str);
|
||||
str = (char *)a->data.v;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ static int tolua_building_set_info(lua_State * L)
|
|||
const char *info = tolua_tostring(L, 2, 0);
|
||||
free(self->display);
|
||||
if (info)
|
||||
self->display = strdup(info);
|
||||
self->display = _strdup(info);
|
||||
else
|
||||
self->display = NULL;
|
||||
return 0;
|
||||
|
|
|
@ -24,6 +24,7 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/attrib.h>
|
||||
|
||||
#include <tolua.h>
|
||||
#include <lua.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -104,7 +105,7 @@ static int tolua_hashtable_set_string(lua_State * L)
|
|||
attrib *a = a_find(*self, &at_object);
|
||||
variant val;
|
||||
|
||||
val.v = strdup(value);
|
||||
val.v = _strdup(value);
|
||||
|
||||
for (; a && a->type == &at_object; a = a->next) {
|
||||
if (strcmp(object_name(a), name) == 0) {
|
||||
|
|
|
@ -574,7 +574,7 @@ static int tolua_plane_set_name(lua_State * L)
|
|||
const char *str = tolua_tostring(L, 2, 0);
|
||||
free(self->name);
|
||||
if (str)
|
||||
self->name = strdup(str);
|
||||
self->name = _strdup(str);
|
||||
else
|
||||
self->name = 0;
|
||||
return 0;
|
||||
|
|
|
@ -87,9 +87,9 @@ static int parse_archetypes(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
assert(propValue != NULL);
|
||||
arch->name[0] = strdup((const char *)propValue);
|
||||
arch->name[0] = _strdup((const char *)propValue);
|
||||
sprintf(zName, "%s_p", arch->name[0]);
|
||||
arch->name[1] = strdup(zName);
|
||||
arch->name[1] = _strdup(zName);
|
||||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "equip");
|
||||
|
@ -130,11 +130,11 @@ static int parse_archetypes(xmlDocPtr doc)
|
|||
arch->rules[k].allow = (rule->name[0] == 'a');
|
||||
|
||||
propValue = xmlGetProp(rule, BAD_CAST "property");
|
||||
arch->rules[k].property = strdup((const char *)propValue);
|
||||
arch->rules[k].property = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(rule, BAD_CAST "value");
|
||||
arch->rules[k].value = strdup((const char *)propValue);
|
||||
arch->rules[k].value = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ faction *createmonsters(int no)
|
|||
/* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei
|
||||
* no 0 muss keine orders einreichen! */
|
||||
|
||||
f->email = strdup("monsters@eressea.de");
|
||||
f->name = strdup("Monster");
|
||||
f->email = _strdup("monsters@eressea.de");
|
||||
f->name = _strdup("Monster");
|
||||
f->alive = 1;
|
||||
f->options = (char)(1 << O_REPORT);
|
||||
addlist(&factions, f);
|
||||
|
|
|
@ -123,7 +123,7 @@ static const char *add_translation(const char *key, const char *value)
|
|||
junkyard = junkyard->next;
|
||||
} else
|
||||
t = malloc(sizeof(translation));
|
||||
t->key = strdup(key);
|
||||
t->key = _strdup(key);
|
||||
t->value = value;
|
||||
t->next = translation_table[kk];
|
||||
translation_table[kk] = t;
|
||||
|
|
|
@ -1448,7 +1448,7 @@ static void remove_idle_players(void)
|
|||
}
|
||||
if (fval(f, FFL_OVERRIDE)) {
|
||||
free(f->override);
|
||||
f->override = strdup(itoa36(rng_int()));
|
||||
f->override = _strdup(itoa36(rng_int()));
|
||||
freset(f, FFL_OVERRIDE);
|
||||
}
|
||||
if (turn != f->lastorders) {
|
||||
|
@ -1835,7 +1835,7 @@ int display_cmd(unit * u, struct order *ord)
|
|||
const char *s2 = getstrtoken();
|
||||
|
||||
free(*s);
|
||||
*s = strdup(s2);
|
||||
*s = _strdup(s2);
|
||||
if (strlen(s2) >= DISPLAYSIZE) {
|
||||
(*s)[DISPLAYSIZE] = 0;
|
||||
}
|
||||
|
@ -1871,7 +1871,7 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2)
|
|||
* names, phishing-style? () come to mind. */
|
||||
|
||||
free(*s);
|
||||
*s = strdup(s2);
|
||||
*s = _strdup(s2);
|
||||
if (strlen(s2) >= NAMESIZE) {
|
||||
(*s)[NAMESIZE] = 0;
|
||||
}
|
||||
|
@ -2345,7 +2345,7 @@ int banner_cmd(unit * u, struct order *ord)
|
|||
skip_token();
|
||||
|
||||
free(u->faction->banner);
|
||||
u->faction->banner = strdup(getstrtoken());
|
||||
u->faction->banner = _strdup(getstrtoken());
|
||||
add_message(&u->faction->msgs, msg_message("changebanner", "value",
|
||||
u->faction->banner));
|
||||
|
||||
|
@ -2404,9 +2404,9 @@ int password_cmd(unit * u, struct order *ord)
|
|||
free(u->faction->passw);
|
||||
if (!pwok) {
|
||||
cmistake(u, ord, 283, MSG_EVENT);
|
||||
u->faction->passw = strdup(itoa36(rng_int()));
|
||||
u->faction->passw = _strdup(itoa36(rng_int()));
|
||||
} else {
|
||||
u->faction->passw = strdup(pwbuf);
|
||||
u->faction->passw = _strdup(pwbuf);
|
||||
}
|
||||
fset(u->faction, FFL_OVERRIDE);
|
||||
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
||||
|
@ -3582,7 +3582,7 @@ void new_units(void)
|
|||
|
||||
token = getstrtoken();
|
||||
if (token && token[0]) {
|
||||
name = strdup(token);
|
||||
name = _strdup(token);
|
||||
}
|
||||
u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
|
||||
if (name != NULL)
|
||||
|
@ -4478,7 +4478,7 @@ static int warn_password(void)
|
|||
}
|
||||
if (!pwok) {
|
||||
free(f->passw);
|
||||
f->passw = strdup(itoa36(rng_int()));
|
||||
f->passw = _strdup(itoa36(rng_int()));
|
||||
ADDMSG(&f->msgs, msg_message("illegal_password", "newpass", f->passw));
|
||||
}
|
||||
f = f->next;
|
||||
|
|
|
@ -923,7 +923,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
e = e->next;
|
||||
if (!e) {
|
||||
e = calloc(sizeof(struct edge), 1);
|
||||
e->name = strdup(name);
|
||||
e->name = _strdup(name);
|
||||
e->transparent = transparent;
|
||||
e->next = edges;
|
||||
edges = e;
|
||||
|
|
|
@ -75,7 +75,7 @@ alliance *makealliance(int id, const char *name)
|
|||
al = calloc(1, sizeof(alliance));
|
||||
al->id = id;
|
||||
if (name) {
|
||||
al->name = strdup(name);
|
||||
al->name = _strdup(name);
|
||||
} else {
|
||||
al->flags |= ALF_NON_ALLIED;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ void alliance_setname(alliance * self, const char *name)
|
|||
{
|
||||
free(self->name);
|
||||
if (name)
|
||||
self->name = strdup(name);
|
||||
self->name = _strdup(name);
|
||||
else
|
||||
self->name = NULL;
|
||||
}
|
||||
|
|
|
@ -104,9 +104,9 @@ static int lc_read(struct attrib *a, void *owner, struct storage *store)
|
|||
if (strcmp(lbuf, NULLSTRING) == 0)
|
||||
data->param = NULL;
|
||||
else
|
||||
data->param = strdup(lbuf);
|
||||
data->param = _strdup(lbuf);
|
||||
} else {
|
||||
data->param = strdup(NULLSTRING);
|
||||
data->param = _strdup(NULLSTRING);
|
||||
}
|
||||
if (result == 0 && !data->b) {
|
||||
return AT_READ_FAIL;
|
||||
|
@ -488,7 +488,7 @@ building *new_building(const struct building_type * btype, region * r,
|
|||
}
|
||||
assert(bname);
|
||||
slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b));
|
||||
b->name = strdup(bname);
|
||||
b->name = _strdup(bname);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -678,7 +678,7 @@ void building_setname(building * self, const char *name)
|
|||
{
|
||||
free(self->name);
|
||||
if (name)
|
||||
self->name = strdup(name);
|
||||
self->name = _strdup(name);
|
||||
else
|
||||
self->name = NULL;
|
||||
}
|
||||
|
@ -688,9 +688,9 @@ void building_addaction(building * b, const char *fname, const char *param)
|
|||
attrib *a = a_add(&b->attribs, a_new(&at_building_action));
|
||||
building_action *data = (building_action *) a->data.v;
|
||||
data->b = b;
|
||||
data->fname = strdup(fname);
|
||||
data->fname = _strdup(fname);
|
||||
if (param) {
|
||||
data->param = strdup(param);
|
||||
data->param = _strdup(param);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_register_building(CuTest * tc)
|
|||
test_cleanup();
|
||||
|
||||
btype = (building_type *)calloc(sizeof(building_type), 1);
|
||||
btype->_name = strdup("herp");
|
||||
btype->_name = _strdup("herp");
|
||||
bt_register(btype);
|
||||
|
||||
CuAssertPtrNotNull(tc, bt_find("herp"));
|
||||
|
|
|
@ -168,7 +168,7 @@ int AllianceAuto(void)
|
|||
gamecookie = global.cookie;
|
||||
value = 0;
|
||||
if (str != NULL) {
|
||||
char *sstr = strdup(str);
|
||||
char *sstr = _strdup(str);
|
||||
char *tok = strtok(sstr, " ");
|
||||
while (tok) {
|
||||
value |= ally_flag(tok, -1);
|
||||
|
@ -195,7 +195,7 @@ int HelpMask(void)
|
|||
gamecookie = global.cookie;
|
||||
rule = 0;
|
||||
if (str != NULL) {
|
||||
char *sstr = strdup(str);
|
||||
char *sstr = _strdup(str);
|
||||
char *tok = strtok(sstr, " ");
|
||||
while (tok) {
|
||||
rule |= ally_flag(tok, -1);
|
||||
|
@ -218,7 +218,7 @@ int AllianceRestricted(void)
|
|||
gamecookie = global.cookie;
|
||||
rule = 0;
|
||||
if (str != NULL) {
|
||||
char *sstr = strdup(str);
|
||||
char *sstr = _strdup(str);
|
||||
char *tok = strtok(sstr, " ");
|
||||
while (tok) {
|
||||
rule |= ally_flag(tok, -1);
|
||||
|
@ -1542,7 +1542,7 @@ void addstrlist(strlist ** SP, const char *s)
|
|||
{
|
||||
strlist *slist = malloc(sizeof(strlist));
|
||||
slist->next = NULL;
|
||||
slist->s = strdup(s);
|
||||
slist->s = _strdup(s);
|
||||
addlist(SP, slist);
|
||||
}
|
||||
|
||||
|
@ -2015,7 +2015,7 @@ static void init_locale(const struct locale *lang)
|
|||
str = "gwyrrd illaun draig cerddor tybied";
|
||||
}
|
||||
|
||||
sstr = strdup(str);
|
||||
sstr = _strdup(str);
|
||||
tok = strtok(sstr, " ");
|
||||
while (tok) {
|
||||
for (i = 0; i != MAXMAGIETYP; ++i) {
|
||||
|
@ -2151,14 +2151,14 @@ void set_param(struct param **p, const char *key, const char *data)
|
|||
while (*p != NULL) {
|
||||
if (strcmp((*p)->name, key) == 0) {
|
||||
free((*p)->data);
|
||||
(*p)->data = strdup(data);
|
||||
(*p)->data = _strdup(data);
|
||||
return;
|
||||
}
|
||||
p = &(*p)->next;
|
||||
}
|
||||
*p = malloc(sizeof(param));
|
||||
(*p)->name = strdup(key);
|
||||
(*p)->data = strdup(data);
|
||||
(*p)->name = _strdup(key);
|
||||
(*p)->data = _strdup(data);
|
||||
(*p)->next = NULL;
|
||||
}
|
||||
|
||||
|
@ -2262,7 +2262,7 @@ unsigned int getguard(const unit * u)
|
|||
}
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *strdup(const char *s)
|
||||
char *_strdup(const char *s)
|
||||
{
|
||||
return strcpy((char *)malloc(sizeof(char) * (strlen(s) + 1)), s);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ equipment *create_equipment(const char *eqname)
|
|||
int i = eq ? strcmp(eq->name, eqname) : 1;
|
||||
if (i > 0) {
|
||||
eq = (equipment *)calloc(1, sizeof(equipment));
|
||||
eq->name = strdup(eqname);
|
||||
eq->name = _strdup(eqname);
|
||||
eq->next = *eqp;
|
||||
memset(eq->skills, 0, sizeof(eq->skills));
|
||||
*eqp = eq;
|
||||
|
@ -76,7 +76,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value)
|
|||
{
|
||||
if (eq != NULL) {
|
||||
if (value != NULL) {
|
||||
eq->skills[sk] = strdup(value);
|
||||
eq->skills[sk] = _strdup(value);
|
||||
} else if (eq->skills[sk]) {
|
||||
free(eq->skills[sk]);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ equipment_setitem(equipment * eq, const item_type * itype, const char *value)
|
|||
if (idata == NULL) {
|
||||
idata = (itemdata *) malloc(sizeof(itemdata));
|
||||
idata->itype = itype;
|
||||
idata->value = strdup(value);
|
||||
idata->value = _strdup(value);
|
||||
idata->next = eq->items;
|
||||
eq->items = idata;
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ faction *addfaction(const char *email, const char *password,
|
|||
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
|
||||
}
|
||||
|
||||
f->override = strdup(itoa36(rng_int()));
|
||||
f->override = _strdup(itoa36(rng_int()));
|
||||
faction_setpassword(f, password);
|
||||
|
||||
f->alliance_joindate = turn;
|
||||
|
@ -228,7 +228,7 @@ faction *addfaction(const char *email, const char *password,
|
|||
fhash(f);
|
||||
|
||||
slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f));
|
||||
f->name = strdup(buf);
|
||||
f->name = _strdup(buf);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ void faction_setname(faction * self, const char *name)
|
|||
{
|
||||
free(self->name);
|
||||
if (name)
|
||||
self->name = strdup(name);
|
||||
self->name = _strdup(name);
|
||||
}
|
||||
|
||||
const char *faction_getemail(const faction * self)
|
||||
|
@ -467,7 +467,7 @@ void faction_setemail(faction * self, const char *email)
|
|||
{
|
||||
free(self->email);
|
||||
if (email)
|
||||
self->email = strdup(email);
|
||||
self->email = _strdup(email);
|
||||
}
|
||||
|
||||
const char *faction_getbanner(const faction * self)
|
||||
|
@ -479,16 +479,16 @@ void faction_setbanner(faction * self, const char *banner)
|
|||
{
|
||||
free(self->banner);
|
||||
if (banner)
|
||||
self->banner = strdup(banner);
|
||||
self->banner = _strdup(banner);
|
||||
}
|
||||
|
||||
void faction_setpassword(faction * f, const char *passw)
|
||||
{
|
||||
free(f->passw);
|
||||
if (passw)
|
||||
f->passw = strdup(passw);
|
||||
f->passw = _strdup(passw);
|
||||
else
|
||||
f->passw = strdup(itoa36(rng_int()));
|
||||
f->passw = _strdup(itoa36(rng_int()));
|
||||
}
|
||||
|
||||
bool valid_race(const struct faction *f, const struct race *rc)
|
||||
|
|
|
@ -58,7 +58,7 @@ static group *new_group(faction * f, const char *name, int gid)
|
|||
*gp = g;
|
||||
|
||||
maxgid = MAX(gid, maxgid);
|
||||
g->name = strdup(name);
|
||||
g->name = _strdup(name);
|
||||
g->gid = gid;
|
||||
|
||||
g->nexthash = ghash[index];
|
||||
|
|
|
@ -158,9 +158,9 @@ resource_type *new_resourcetype(const char **names, const char **appearances,
|
|||
rtype = (resource_type *)calloc(sizeof(resource_type), 1);
|
||||
|
||||
for (i = 0; i != 2; ++i) {
|
||||
rtype->_name[i] = strdup(names[i]);
|
||||
rtype->_name[i] = _strdup(names[i]);
|
||||
if (appearances)
|
||||
rtype->_appearance[i] = strdup(appearances[i]);
|
||||
rtype->_appearance[i] = _strdup(appearances[i]);
|
||||
else
|
||||
rtype->_appearance[i] = NULL;
|
||||
}
|
||||
|
@ -239,8 +239,8 @@ weapon_type *new_weapontype(item_type * itype,
|
|||
|
||||
wtype = calloc(sizeof(weapon_type), 1);
|
||||
if (damage) {
|
||||
wtype->damage[0] = strdup(damage[0]);
|
||||
wtype->damage[1] = strdup(damage[1]);
|
||||
wtype->damage[0] = _strdup(damage[0]);
|
||||
wtype->damage[1] = _strdup(damage[1]);
|
||||
}
|
||||
wtype->defmod = defmod;
|
||||
wtype->flags |= wflags;
|
||||
|
@ -1230,9 +1230,9 @@ void test_clear_resources(void)
|
|||
|
||||
void register_resources(void)
|
||||
{
|
||||
static bool registered = false;
|
||||
if (registered) return;
|
||||
registered = true;
|
||||
static bool registered = false;
|
||||
if (registered) return;
|
||||
registered = true;
|
||||
|
||||
register_function((pf_generic) mod_elves_only, "mod_elves_only");
|
||||
register_function((pf_generic) mod_dwarves_only, "mod_dwarves_only");
|
||||
|
|
|
@ -1807,7 +1807,7 @@ static int addparam_string(const char *const param[], spllprm ** spobjp)
|
|||
|
||||
spobj->flag = 0;
|
||||
spobj->typ = SPP_STRING;
|
||||
spobj->data.xs = strdup(param[0]);
|
||||
spobj->data.xs = _strdup(param[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2682,7 +2682,7 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
size *= 2;
|
||||
params = (char**)realloc(params, sizeof(char *) * size);
|
||||
}
|
||||
params[p++] = strdup(s);
|
||||
params[p++] = _strdup(s);
|
||||
}
|
||||
params[p] = 0;
|
||||
args =
|
||||
|
|
|
@ -139,7 +139,7 @@ static char *get_command(const order * ord, char *sbuffer, size_t size)
|
|||
char *getcommand(const order * ord)
|
||||
{
|
||||
char sbuffer[DISPLAYSIZE * 2];
|
||||
return strdup(get_command(ord, sbuffer, sizeof(sbuffer)));
|
||||
return _strdup(get_command(ord, sbuffer, sizeof(sbuffer)));
|
||||
}
|
||||
|
||||
void free_order(order * ord)
|
||||
|
@ -217,7 +217,7 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
|
|||
data->_str[len + 1] = '\"';
|
||||
data->_str[len + 2] = '\0';
|
||||
} else {
|
||||
data->_str = strdup(skname);
|
||||
data->_str = _strdup(skname);
|
||||
}
|
||||
data->_refcount = 1;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
|
|||
data = (order_data *) malloc(sizeof(order_data));
|
||||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
data->_str = s ? strdup(s) : NULL;
|
||||
data->_str = s ? _strdup(s) : NULL;
|
||||
data->_refcount = 1;
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ plane *create_new_plane(int id, const char *name, int minx, int maxx, int miny,
|
|||
pl->next = NULL;
|
||||
pl->id = id;
|
||||
if (name)
|
||||
pl->name = strdup(name);
|
||||
pl->name = _strdup(name);
|
||||
pl->minx = minx;
|
||||
pl->maxx = maxx;
|
||||
pl->miny = miny;
|
||||
|
|
|
@ -108,13 +108,13 @@ race *rc_new(const char *zName)
|
|||
assert(strchr(zName, ' ') == NULL);
|
||||
}
|
||||
strcpy(zBuffer, zName);
|
||||
rc->_name[0] = strdup(zBuffer);
|
||||
rc->_name[0] = _strdup(zBuffer);
|
||||
sprintf(zBuffer, "%s_p", zName);
|
||||
rc->_name[1] = strdup(zBuffer);
|
||||
rc->_name[1] = _strdup(zBuffer);
|
||||
sprintf(zBuffer, "%s_d", zName);
|
||||
rc->_name[2] = strdup(zBuffer);
|
||||
rc->_name[2] = _strdup(zBuffer);
|
||||
sprintf(zBuffer, "%s_x", zName);
|
||||
rc->_name[3] = strdup(zBuffer);
|
||||
rc->_name[3] = _strdup(zBuffer);
|
||||
rc->precombatspell = NULL;
|
||||
|
||||
rc->attack[0].type = AT_COMBATSPELL;
|
||||
|
@ -172,7 +172,7 @@ extern void add_raceprefix(const char *prefix)
|
|||
size *= 2;
|
||||
race_prefixes = realloc(race_prefixes, size * sizeof(char *));
|
||||
}
|
||||
race_prefixes[next++] = strdup(prefix);
|
||||
race_prefixes[next++] = _strdup(prefix);
|
||||
race_prefixes[next] = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ static dir_lookup *dir_name_lookup;
|
|||
void register_special_direction(const char *name)
|
||||
{
|
||||
struct locale *lang;
|
||||
char *str = strdup(name);
|
||||
char *str = _strdup(name);
|
||||
|
||||
for (lang = locales; lang; lang = nextlocale(lang)) {
|
||||
void **tokens = get_translations(lang, UT_SPECDIR);
|
||||
|
@ -260,9 +260,9 @@ static int a_readdirection(attrib * a, void *owner, struct storage *store)
|
|||
cstring_i(lbuf);
|
||||
for (; dl; dl = dl->next) {
|
||||
if (strcmp(lbuf, dl->oldname) == 0) {
|
||||
d->keyword = strdup(dl->name);
|
||||
d->keyword = _strdup(dl->name);
|
||||
sprintf(lbuf, "%s_desc", d->keyword);
|
||||
d->desc = strdup(dl->name);
|
||||
d->desc = _strdup(dl->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -335,8 +335,8 @@ attrib *create_special_direction(region * r, region * rt, int duration,
|
|||
d->x = rt->x;
|
||||
d->y = rt->y;
|
||||
d->duration = duration;
|
||||
d->desc = strdup(desc);
|
||||
d->keyword = strdup(keyword);
|
||||
d->desc = _strdup(desc);
|
||||
d->keyword = _strdup(keyword);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
@ -1557,7 +1557,7 @@ faction *update_owners(region * r)
|
|||
void region_setinfo(struct region *r, const char *info)
|
||||
{
|
||||
free(r->display);
|
||||
r->display = info ? strdup(info) : 0;
|
||||
r->display = info ? _strdup(info) : 0;
|
||||
}
|
||||
|
||||
const char *region_getinfo(const region * r)
|
||||
|
@ -1569,7 +1569,7 @@ void region_setname(struct region *r, const char *name)
|
|||
{
|
||||
if (r->land) {
|
||||
free(r->land->name);
|
||||
r->land->name = name ? strdup(name) : 0;
|
||||
r->land->name = name ? _strdup(name) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1788,7 +1788,7 @@ int reports(void)
|
|||
|
||||
static variant var_copy_string(variant x)
|
||||
{
|
||||
x.v = x.v ? strdup((const char *)x.v) : 0;
|
||||
x.v = x.v ? _strdup((const char *)x.v) : 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ struct rawmaterial_type *rmt_create(const struct resource_type *rtype,
|
|||
const char *name)
|
||||
{
|
||||
rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type));
|
||||
rmtype->name = strdup(name);
|
||||
rmtype->name = _strdup(name);
|
||||
rmtype->rtype = rtype;
|
||||
rmtype->terraform = terraform_default;
|
||||
rmtype->update = NULL;
|
||||
|
|
|
@ -1224,7 +1224,7 @@ faction *readfaction(struct storage * store)
|
|||
if (store->version >= OVERRIDE_VERSION) {
|
||||
f->override = store->r_str(store);
|
||||
} else {
|
||||
f->override = strdup(itoa36(rng_int()));
|
||||
f->override = _strdup(itoa36(rng_int()));
|
||||
}
|
||||
|
||||
store->r_str_buf(store, token, sizeof(token));
|
||||
|
|
|
@ -185,7 +185,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
|||
}
|
||||
assert(sname);
|
||||
slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh));
|
||||
sh->name = strdup(buffer);
|
||||
sh->name = _strdup(buffer);
|
||||
shash(sh);
|
||||
if (r) {
|
||||
addlist(&r->ships, sh);
|
||||
|
@ -337,7 +337,7 @@ void ship_setname(ship * self, const char *name)
|
|||
{
|
||||
free(self->name);
|
||||
if (name)
|
||||
self->name = strdup(name);
|
||||
self->name = _strdup(name);
|
||||
else
|
||||
self->name = NULL;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_register_ship(CuTest * tc)
|
|||
test_cleanup();
|
||||
|
||||
stype = (ship_type *)calloc(sizeof(ship_type), 1);
|
||||
stype->name[0] = strdup("herp");
|
||||
stype->name[0] = _strdup("herp");
|
||||
st_register(stype);
|
||||
|
||||
CuAssertPtrNotNull(tc, st_find("herp"));
|
||||
|
|
|
@ -64,7 +64,7 @@ spell * create_spell(const char * name, unsigned int id)
|
|||
len = cb_new_kv(name, len, &sp, sizeof(sp), buffer);
|
||||
if (cb_insert(&cb_spells, buffer, len)) {
|
||||
sp->id = id ? id : hashstring(name);
|
||||
sp->sname = strdup(name);
|
||||
sp->sname = _strdup(name);
|
||||
add_spell(&spells, sp);
|
||||
return sp;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
spellbook * create_spellbook(const char * name)
|
||||
{
|
||||
spellbook *result = (spellbook *)malloc(sizeof(spellbook));
|
||||
result->name = name ? strdup(name) : 0;
|
||||
result->name = name ? _strdup(name) : 0;
|
||||
result->spells = 0;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ void usetprivate(unit * u, const char *str)
|
|||
a = a_add(&u->attribs, a_new(&at_private));
|
||||
if (a->data.v)
|
||||
free(a->data.v);
|
||||
a->data.v = strdup((const char *)str);
|
||||
a->data.v = _strdup((const char *)str);
|
||||
}
|
||||
|
||||
/*********************/
|
||||
|
@ -1483,7 +1483,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
|
|||
if (!dname) {
|
||||
name_unit(u);
|
||||
} else {
|
||||
u->name = strdup(dname);
|
||||
u->name = _strdup(dname);
|
||||
}
|
||||
|
||||
if (creator) {
|
||||
|
@ -1581,7 +1581,7 @@ void unit_setname(unit * u, const char *name)
|
|||
{
|
||||
free(u->name);
|
||||
if (name)
|
||||
u->name = strdup(name);
|
||||
u->name = _strdup(name);
|
||||
else
|
||||
u->name = NULL;
|
||||
}
|
||||
|
@ -1595,7 +1595,7 @@ void unit_setinfo(unit * u, const char *info)
|
|||
{
|
||||
free(u->display);
|
||||
if (info)
|
||||
u->display = strdup(info);
|
||||
u->display = _strdup(info);
|
||||
else
|
||||
u->display = NULL;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ static building_type *bt_get_or_create(const char *name)
|
|||
building_type *btype = bt_find(name);
|
||||
if (btype == NULL) {
|
||||
btype = calloc(sizeof(building_type), 1);
|
||||
btype->_name = strdup(name);
|
||||
btype->_name = _strdup(name);
|
||||
bt_register(btype);
|
||||
}
|
||||
return btype;
|
||||
|
@ -403,7 +403,7 @@ static int parse_calendar(xmlDocPtr doc)
|
|||
first_turn = xml_ivalue(calendar, "start", first_turn);
|
||||
if (propValue) {
|
||||
free(agename);
|
||||
agename = strdup(mkname("calendar", (const char *)propValue));
|
||||
agename = _strdup(mkname("calendar", (const char *)propValue));
|
||||
xmlFree(propValue);
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ static int parse_calendar(xmlDocPtr doc)
|
|||
xmlNodePtr week = nsetWeeks->nodeTab[i];
|
||||
xmlChar *propValue = xmlGetProp(week, BAD_CAST "name");
|
||||
if (propValue) {
|
||||
weeknames[i] = strdup(mkname("calendar", (const char *)propValue));
|
||||
weeknames[i] = _strdup(mkname("calendar", (const char *)propValue));
|
||||
weeknames2[i] = malloc(strlen(weeknames[i]) + 3);
|
||||
sprintf(weeknames2[i], "%s_d", weeknames[i]);
|
||||
xmlFree(propValue);
|
||||
|
@ -444,7 +444,7 @@ static int parse_calendar(xmlDocPtr doc)
|
|||
xmlChar *propValue = xmlGetProp(season, BAD_CAST "name");
|
||||
if (propValue) {
|
||||
seasonnames[i] =
|
||||
strdup(mkname("calendar", (const char *)propValue));
|
||||
_strdup(mkname("calendar", (const char *)propValue));
|
||||
xmlFree(propValue);
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ static int parse_calendar(xmlDocPtr doc)
|
|||
xmlFree(newyear);
|
||||
newyear = NULL;
|
||||
}
|
||||
monthnames[i] = strdup(mkname("calendar", (const char *)propValue));
|
||||
monthnames[i] = _strdup(mkname("calendar", (const char *)propValue));
|
||||
xmlFree(propValue);
|
||||
}
|
||||
for (j = 0; j != seasons; ++j) {
|
||||
|
@ -542,7 +542,7 @@ static int parse_ships(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
assert(propValue != NULL);
|
||||
st->name[0] = strdup((const char *)propValue);
|
||||
st->name[0] = _strdup((const char *)propValue);
|
||||
st->name[1] =
|
||||
strcat(strcpy(malloc(strlen(st->name[0]) + 3), st->name[0]), "_a");
|
||||
xmlFree(propValue);
|
||||
|
@ -746,7 +746,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
|||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "value");
|
||||
wtype->damage[pos] = gc_add(strdup((const char *)propValue));
|
||||
wtype->damage[pos] = gc_add(_strdup((const char *)propValue));
|
||||
if (k == 0)
|
||||
wtype->damage[1 - pos] = wtype->damage[pos];
|
||||
xmlFree(propValue);
|
||||
|
@ -1034,7 +1034,7 @@ static int parse_resources(xmlDocPtr doc)
|
|||
/* dependency from another item, was created earlier */
|
||||
rtype->flags |= flags;
|
||||
if (appearance) {
|
||||
rtype->_appearance[0] = strdup((const char *)appearance);
|
||||
rtype->_appearance[0] = _strdup((const char *)appearance);
|
||||
rtype->_appearance[1] = appearancep;
|
||||
free(appearancep);
|
||||
}
|
||||
|
@ -1547,13 +1547,13 @@ static int parse_spells(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "parameters");
|
||||
if (propValue) {
|
||||
sp->parameter = strdup((const char *)propValue);
|
||||
sp->parameter = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "syntax");
|
||||
if (propValue) {
|
||||
sp->syntax = strdup((const char *)propValue);
|
||||
sp->syntax = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
#ifdef TODO /* no longer need it, spellbooks! */
|
||||
|
@ -1730,7 +1730,7 @@ static int parse_races(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "damage");
|
||||
assert(propValue != NULL);
|
||||
rc->def_damage = strdup((const char *)propValue);
|
||||
rc->def_damage = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
rc->magres = (float)xml_fvalue(node, "magres", 0.0);
|
||||
|
@ -1951,7 +1951,7 @@ static int parse_races(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "damage");
|
||||
if (propValue != NULL) {
|
||||
attack->data.dice = strdup((const char *)propValue);
|
||||
attack->data.dice = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
} else {
|
||||
attack->data.sp = xml_spell(node, "spell");
|
||||
|
@ -1997,7 +1997,7 @@ static int parse_terrains(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
assert(propValue != NULL);
|
||||
terrain->_name = strdup((const char *)propValue);
|
||||
terrain->_name = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
terrain->max_road = (short)xml_ivalue(node, "road", 0);
|
||||
|
@ -2074,17 +2074,17 @@ static int parse_terrains(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(nodeProd, BAD_CAST "level");
|
||||
assert(propValue);
|
||||
terrain->production[k].startlevel = strdup((const char *)propValue);
|
||||
terrain->production[k].startlevel = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(nodeProd, BAD_CAST "base");
|
||||
assert(propValue);
|
||||
terrain->production[k].base = strdup((const char *)propValue);
|
||||
terrain->production[k].base = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(nodeProd, BAD_CAST "div");
|
||||
assert(propValue);
|
||||
terrain->production[k].divisor = strdup((const char *)propValue);
|
||||
terrain->production[k].divisor = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
terrain->production[k].chance =
|
||||
|
@ -2145,7 +2145,7 @@ static int parse_messages(xmlDocPtr doc)
|
|||
(const char *)propType);
|
||||
xmlFree(propName);
|
||||
xmlFree(propType);
|
||||
argv[k] = strdup(zBuffer);
|
||||
argv[k] = _strdup(zBuffer);
|
||||
}
|
||||
argv[result->nodesetval->nodeNr] = NULL;
|
||||
}
|
||||
|
@ -2321,7 +2321,7 @@ static int parse_main(xmlDocPtr doc)
|
|||
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
if (propValue != NULL) {
|
||||
global.gamename = strdup((const char *)propValue);
|
||||
global.gamename = _strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,9 +275,9 @@ static void make_temple(region * r)
|
|||
|
||||
b = new_building(btype, r, NULL);
|
||||
b->size = btype->maxsize;
|
||||
b->name = strdup("Igjarjuk's Tempel der Schreie");
|
||||
b->name = _strdup("Igjarjuk's Tempel der Schreie");
|
||||
b->display =
|
||||
strdup
|
||||
_strdup
|
||||
("Ein Schrein aus spitzen Knochen und lodernden Flammen, gewidmet dem Wyrm der Wyrme");
|
||||
a_add(&b->attribs, a_new(&at_hurting))->data.v = b;
|
||||
}
|
||||
|
@ -338,11 +338,11 @@ static void guardian_faction(plane * pl, int id)
|
|||
|
||||
if (!f) {
|
||||
f = calloc(1, sizeof(faction));
|
||||
f->banner = strdup("Sie dienen dem großen Wyrm");
|
||||
f->passw = strdup(itoa36(rng_int()));
|
||||
f->override = strdup(itoa36(rng_int()));
|
||||
f->banner = _strdup("Sie dienen dem großen Wyrm");
|
||||
f->passw = _strdup(itoa36(rng_int()));
|
||||
f->override = _strdup(itoa36(rng_int()));
|
||||
set_email(&f->email, "igjarjuk@eressea.de");
|
||||
f->name = strdup("Igjarjuks Kundschafter");
|
||||
f->name = _strdup("Igjarjuks Kundschafter");
|
||||
f->race = new_race[RC_ILLUSION];
|
||||
f->age = turn;
|
||||
f->locale = find_locale("de");
|
||||
|
@ -480,9 +480,9 @@ static void init_volcano(void)
|
|||
terraform(arena_center, T_VOLCANO_SMOKING);
|
||||
b = new_building(bt_find("caldera"), r, NULL);
|
||||
b->size = 1;
|
||||
b->name = strdup("Igjarjuk's Schlund");
|
||||
b->name = _strdup("Igjarjuk's Schlund");
|
||||
b->display =
|
||||
strdup
|
||||
_strdup
|
||||
("Feurige Lava fließt aus dem Krater des großen Vulkans. Alles wird von ihr verschlungen.");
|
||||
add_trigger(&b->attribs, "timer", trigger_caldera(b));
|
||||
tt_register(&tt_caldera);
|
||||
|
|
|
@ -267,7 +267,7 @@ newfaction *read_newfactions(const char *filename)
|
|||
log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
|
||||
continue;
|
||||
}
|
||||
nf->password = strdup(password);
|
||||
nf->password = _strdup(password);
|
||||
nf->race = rc_find(race);
|
||||
nf->subscription = subscription;
|
||||
if (alliances != NULL) {
|
||||
|
|
|
@ -662,10 +662,10 @@ faction *gm_addfaction(const char *email, plane * p, region * r)
|
|||
|
||||
/* GM faction */
|
||||
a_add(&f->attribs, make_key(atoi36("quest")));
|
||||
f->banner = strdup("quest faction");
|
||||
f->name = strdup("quest faction");
|
||||
f->passw = strdup(itoa36(rng_int()));
|
||||
f->override = strdup(itoa36(rng_int()));
|
||||
f->banner = _strdup("quest faction");
|
||||
f->name = _strdup("quest faction");
|
||||
f->passw = _strdup(itoa36(rng_int()));
|
||||
f->override = _strdup(itoa36(rng_int()));
|
||||
if (set_email(&f->email, email) != 0) {
|
||||
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
|
||||
}
|
||||
|
|
|
@ -247,12 +247,6 @@ typedef struct _stat stat_type;
|
|||
|
||||
#define TOLUA_CAST (char*)
|
||||
|
||||
#if !defined(HAVE_STRDUP)
|
||||
# if defined(HAVE__STRDUP)
|
||||
# define strdup(s) _strdup(s)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE__STRDUP)
|
||||
# if defined(HAVE_STRDUP)
|
||||
# define _strdup(s) strdup(s)
|
||||
|
|
|
@ -118,7 +118,7 @@ test_create_terrain(const char * name, unsigned int flags)
|
|||
|
||||
assert(!get_terrain(name));
|
||||
t = (terrain_type*)calloc(1, sizeof(terrain_type));
|
||||
t->_name = strdup(name);
|
||||
t->_name = _strdup(name);
|
||||
t->flags = flags;
|
||||
register_terrain(t);
|
||||
return t;
|
||||
|
@ -141,8 +141,8 @@ ship * test_create_ship(region * r, const ship_type * stype)
|
|||
ship_type * test_create_shiptype(const char ** names)
|
||||
{
|
||||
ship_type * stype = (ship_type*)calloc(sizeof(ship_type), 1);
|
||||
stype->name[0] = strdup(names[0]);
|
||||
stype->name[1] = strdup(names[1]);
|
||||
stype->name[0] = _strdup(names[0]);
|
||||
stype->name[1] = _strdup(names[1]);
|
||||
locale_setstring(default_locale, names[0], names[0]);
|
||||
st_register(stype);
|
||||
return stype;
|
||||
|
@ -152,7 +152,7 @@ building_type * test_create_buildingtype(const char * name)
|
|||
{
|
||||
building_type * btype = (building_type*)calloc(sizeof(building_type), 1);
|
||||
btype->flags = BTF_NAMECHANGE;
|
||||
btype->_name = strdup(name);
|
||||
btype->_name = _strdup(name);
|
||||
locale_setstring(default_locale, name, name);
|
||||
bt_register(btype);
|
||||
return btype;
|
||||
|
|
|
@ -85,7 +85,7 @@ static void do_shock(unit * u, const char *reason)
|
|||
}
|
||||
if (u->faction != NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("shock",
|
||||
"mage reason", u, strdup(reason)));
|
||||
"mage reason", u, _strdup(reason)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ static int unitmessage_read(trigger * t, struct storage *store)
|
|||
td->string = store->r_tok(store);
|
||||
td->type = store->r_int(store);
|
||||
td->level = store->r_int(store);
|
||||
td->string = strdup(zText);
|
||||
td->string = _strdup(zText);
|
||||
|
||||
if (result == 0 && td->target == NULL) {
|
||||
return AT_READ_FAIL;
|
||||
|
@ -117,7 +117,7 @@ trigger *trigger_unitmessage(unit * target, const char *string, int type,
|
|||
trigger *t = t_new(&tt_unitmessage);
|
||||
unitmessage_data *td = (unitmessage_data *) t->data.v;
|
||||
td->target = target;
|
||||
td->string = strdup(string);
|
||||
td->string = _strdup(string);
|
||||
td->type = type;
|
||||
td->level = level;
|
||||
return t;
|
||||
|
|
|
@ -147,7 +147,7 @@ static int read_handler(attrib * a, void *owner, struct storage *store)
|
|||
handler_info *hi = (handler_info *) a->data.v;
|
||||
|
||||
store->r_tok_buf(store, zText, sizeof(zText));
|
||||
hi->event = strdup(zText);
|
||||
hi->event = _strdup(zText);
|
||||
read_triggers(store, &hi->triggers);
|
||||
if (hi->triggers != NULL) {
|
||||
return AT_READ_OK;
|
||||
|
@ -194,7 +194,7 @@ void add_trigger(struct attrib **ap, const char *eventname, struct trigger *t)
|
|||
if (a == NULL || a->type != &at_eventhandler) {
|
||||
a = a_add(ap, a_new(&at_eventhandler));
|
||||
td = (handler_info *) a->data.v;
|
||||
td->event = strdup(eventname);
|
||||
td->event = _strdup(eventname);
|
||||
}
|
||||
tp = &td->triggers;
|
||||
while (*tp)
|
||||
|
|
|
@ -131,7 +131,7 @@ int set_email(char **pemail, const char *newmail)
|
|||
free(*pemail);
|
||||
*pemail = 0;
|
||||
if (newmail) {
|
||||
*pemail = strdup(newmail);
|
||||
*pemail = _strdup(newmail);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ locale *make_locale(const char *name)
|
|||
}
|
||||
|
||||
l->hashkey = hkey;
|
||||
l->name = strdup(name);
|
||||
l->name = _strdup(name);
|
||||
l->next = NULL;
|
||||
l->index = nextlocaleindex++;
|
||||
assert(nextlocaleindex <= MAXLOCALES);
|
||||
|
@ -181,8 +181,8 @@ void locale_setstring(locale * lang, const char *key, const char *value)
|
|||
find->nexthash = lang->strings[id];
|
||||
lang->strings[id] = find;
|
||||
find->hashkey = hkey;
|
||||
find->key = strdup(key);
|
||||
find->str = strdup(value);
|
||||
find->key = _strdup(key);
|
||||
find->str = _strdup(value);
|
||||
} else {
|
||||
if (strcmp(find->str, value) != 0) {
|
||||
log_error("duplicate translation '%s' for key %s\n", value, key);
|
||||
|
|
|
@ -26,7 +26,7 @@ insert_selection(list_selection ** p_sel, list_selection * prev,
|
|||
const char *str, void *payload)
|
||||
{
|
||||
list_selection *sel = calloc(sizeof(list_selection), 1);
|
||||
sel->str = strdup(str);
|
||||
sel->str = _strdup(str);
|
||||
sel->data = payload;
|
||||
if (*p_sel) {
|
||||
list_selection *s;
|
||||
|
|
|
@ -45,7 +45,7 @@ message_type *mt_new(const char *name, const char *args[])
|
|||
if (args != NULL)
|
||||
for (nparameters = 0; args[nparameters]; ++nparameters) ;
|
||||
|
||||
mtype->name = strdup(name);
|
||||
mtype->name = _strdup(name);
|
||||
mtype->nparameters = nparameters;
|
||||
if (nparameters > 0) {
|
||||
mtype->pnames = (const char **)malloc(sizeof(char *) * nparameters);
|
||||
|
@ -59,7 +59,7 @@ message_type *mt_new(const char *name, const char *args[])
|
|||
const char *x = args[i];
|
||||
const char *spos = strchr(x, ':');
|
||||
if (spos == NULL) {
|
||||
mtype->pnames[i] = strdup(x);
|
||||
mtype->pnames[i] = _strdup(x);
|
||||
mtype->types[i] = NULL;
|
||||
} else {
|
||||
char *cp = strncpy((char *)malloc(spos - x + 1), x, spos - x);
|
||||
|
|
|
@ -91,7 +91,7 @@ const nrsection *section_add(const char *name)
|
|||
}
|
||||
if (!*mcp) {
|
||||
nrsection *mc = calloc(sizeof(nrsection), 1);
|
||||
mc->name = strdup(name);
|
||||
mc->name = _strdup(name);
|
||||
*mcp = mc;
|
||||
}
|
||||
return *mcp;
|
||||
|
@ -128,14 +128,14 @@ nrt_register(const struct message_type *mtype, const struct locale *lang,
|
|||
nrt->section = NULL;
|
||||
nrtypes[hash] = nrt;
|
||||
assert(string && *string);
|
||||
nrt->string = strdup(string);
|
||||
nrt->string = _strdup(string);
|
||||
*c = '\0';
|
||||
for (i = 0; i != mtype->nparameters; ++i) {
|
||||
if (i != 0)
|
||||
*c++ = ' ';
|
||||
c += strlen(strcpy(c, mtype->pnames[i]));
|
||||
}
|
||||
nrt->vars = strdup(zNames);
|
||||
nrt->vars = _strdup(zNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ void sql_init(const char *filename)
|
|||
{
|
||||
if (sqlfilename != NULL)
|
||||
free(sqlfilename);
|
||||
sqlfilename = strdup(filename);
|
||||
sqlfilename = _strdup(filename);
|
||||
}
|
||||
|
||||
void _sql_print(const char *format, ...)
|
||||
|
|
Loading…
Reference in New Issue