eliminate strdup

The POSIX name for this item is deprecated. Instead, use the ISO C++
conformant name: _strdup.
This commit is contained in:
Enno Rehling 2013-12-29 05:38:58 -08:00
parent 4a5d2d8de9
commit 30b3911637
47 changed files with 143 additions and 148 deletions

View File

@ -185,7 +185,7 @@ struct attrib *object_create(const char *name, object_type type, variant value)
{ {
attrib *a = a_new(&at_object); attrib *a = a_new(&at_object);
object_data *data = (object_data *) a->data.v; object_data *data = (object_data *) a->data.v;
data->name = strdup(name); data->name = _strdup(name);
object_set(a, type, value); object_set(a, type, value);
return a; return a;
@ -200,7 +200,7 @@ void object_set(attrib * a, object_type type, variant value)
data->type = type; data->type = type;
switch (type) { switch (type) {
case TSTRING: case TSTRING:
data->data.str = value.v ? strdup(value.v) : NULL; data->data.str = value.v ? _strdup(value.v) : NULL;
break; break;
case TINTEGER: case TINTEGER:
data->data.i = value.i; data->data.i = value.i;

View File

@ -44,13 +44,13 @@ void set_racename(attrib ** palist, const char *name)
attrib *a = a_find(*palist, &at_racename); attrib *a = a_find(*palist, &at_racename);
if (!a && name) { if (!a && name) {
a = a_add(palist, a_new(&at_racename)); a = a_add(palist, a_new(&at_racename));
a->data.v = strdup(name); a->data.v = _strdup(name);
} else if (a && !name) { } else if (a && !name) {
a_remove(palist, a); a_remove(palist, a);
} else if (a) { } else if (a) {
if (strcmp(a->data.v, name) != 0) { if (strcmp(a->data.v, name) != 0) {
free(a->data.v); free(a->data.v);
a->data.v = strdup(name); a->data.v = _strdup(name);
} }
} }
} }

View File

@ -40,7 +40,7 @@ void set_prefix(attrib ** ap, const char *str)
free(a->data.v); free(a->data.v);
} }
assert(a->type == &at_raceprefix); assert(a->type == &at_raceprefix);
a->data.v = strdup(str); a->data.v = _strdup(str);
} }
const char *get_prefix(const attrib * a) const char *get_prefix(const attrib * a)
@ -52,7 +52,7 @@ const char *get_prefix(const attrib * a)
str = (char *)a->data.v; str = (char *)a->data.v;
/* conversion of old prefixes */ /* conversion of old prefixes */
if (strncmp(str, "prefix_", 7) == 0) { if (strncmp(str, "prefix_", 7) == 0) {
((attrib *) a)->data.v = strdup(str + 7); ((attrib *) a)->data.v = _strdup(str + 7);
free(str); free(str);
str = (char *)a->data.v; str = (char *)a->data.v;
} }

View File

@ -81,7 +81,7 @@ static int tolua_building_set_info(lua_State * L)
const char *info = tolua_tostring(L, 2, 0); const char *info = tolua_tostring(L, 2, 0);
free(self->display); free(self->display);
if (info) if (info)
self->display = strdup(info); self->display = _strdup(info);
else else
self->display = NULL; self->display = NULL;
return 0; return 0;

View File

@ -24,6 +24,7 @@ without prior permission by the authors of Eressea.
#include <util/attrib.h> #include <util/attrib.h>
#include <tolua.h> #include <tolua.h>
#include <lua.h>
#include <assert.h> #include <assert.h>
@ -104,7 +105,7 @@ static int tolua_hashtable_set_string(lua_State * L)
attrib *a = a_find(*self, &at_object); attrib *a = a_find(*self, &at_object);
variant val; variant val;
val.v = strdup(value); val.v = _strdup(value);
for (; a && a->type == &at_object; a = a->next) { for (; a && a->type == &at_object; a = a->next) {
if (strcmp(object_name(a), name) == 0) { if (strcmp(object_name(a), name) == 0) {

View File

@ -574,7 +574,7 @@ static int tolua_plane_set_name(lua_State * L)
const char *str = tolua_tostring(L, 2, 0); const char *str = tolua_tostring(L, 2, 0);
free(self->name); free(self->name);
if (str) if (str)
self->name = strdup(str); self->name = _strdup(str);
else else
self->name = 0; self->name = 0;
return 0; return 0;

View File

@ -87,9 +87,9 @@ static int parse_archetypes(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL); assert(propValue != NULL);
arch->name[0] = strdup((const char *)propValue); arch->name[0] = _strdup((const char *)propValue);
sprintf(zName, "%s_p", arch->name[0]); sprintf(zName, "%s_p", arch->name[0]);
arch->name[1] = strdup(zName); arch->name[1] = _strdup(zName);
xmlFree(propValue); xmlFree(propValue);
propValue = xmlGetProp(node, BAD_CAST "equip"); propValue = xmlGetProp(node, BAD_CAST "equip");
@ -130,11 +130,11 @@ static int parse_archetypes(xmlDocPtr doc)
arch->rules[k].allow = (rule->name[0] == 'a'); arch->rules[k].allow = (rule->name[0] == 'a');
propValue = xmlGetProp(rule, BAD_CAST "property"); propValue = xmlGetProp(rule, BAD_CAST "property");
arch->rules[k].property = strdup((const char *)propValue); arch->rules[k].property = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
propValue = xmlGetProp(rule, BAD_CAST "value"); propValue = xmlGetProp(rule, BAD_CAST "value");
arch->rules[k].value = strdup((const char *)propValue); arch->rules[k].value = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
} }
} }

View File

@ -62,8 +62,8 @@ faction *createmonsters(int no)
/* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei /* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei
* no 0 muss keine orders einreichen! */ * no 0 muss keine orders einreichen! */
f->email = strdup("monsters@eressea.de"); f->email = _strdup("monsters@eressea.de");
f->name = strdup("Monster"); f->name = _strdup("Monster");
f->alive = 1; f->alive = 1;
f->options = (char)(1 << O_REPORT); f->options = (char)(1 << O_REPORT);
addlist(&factions, f); addlist(&factions, f);

View File

@ -123,7 +123,7 @@ static const char *add_translation(const char *key, const char *value)
junkyard = junkyard->next; junkyard = junkyard->next;
} else } else
t = malloc(sizeof(translation)); t = malloc(sizeof(translation));
t->key = strdup(key); t->key = _strdup(key);
t->value = value; t->value = value;
t->next = translation_table[kk]; t->next = translation_table[kk];
translation_table[kk] = t; translation_table[kk] = t;

View File

@ -1448,7 +1448,7 @@ static void remove_idle_players(void)
} }
if (fval(f, FFL_OVERRIDE)) { if (fval(f, FFL_OVERRIDE)) {
free(f->override); free(f->override);
f->override = strdup(itoa36(rng_int())); f->override = _strdup(itoa36(rng_int()));
freset(f, FFL_OVERRIDE); freset(f, FFL_OVERRIDE);
} }
if (turn != f->lastorders) { if (turn != f->lastorders) {
@ -1835,7 +1835,7 @@ int display_cmd(unit * u, struct order *ord)
const char *s2 = getstrtoken(); const char *s2 = getstrtoken();
free(*s); free(*s);
*s = strdup(s2); *s = _strdup(s2);
if (strlen(s2) >= DISPLAYSIZE) { if (strlen(s2) >= DISPLAYSIZE) {
(*s)[DISPLAYSIZE] = 0; (*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. */ * names, phishing-style? () come to mind. */
free(*s); free(*s);
*s = strdup(s2); *s = _strdup(s2);
if (strlen(s2) >= NAMESIZE) { if (strlen(s2) >= NAMESIZE) {
(*s)[NAMESIZE] = 0; (*s)[NAMESIZE] = 0;
} }
@ -2345,7 +2345,7 @@ int banner_cmd(unit * u, struct order *ord)
skip_token(); skip_token();
free(u->faction->banner); free(u->faction->banner);
u->faction->banner = strdup(getstrtoken()); u->faction->banner = _strdup(getstrtoken());
add_message(&u->faction->msgs, msg_message("changebanner", "value", add_message(&u->faction->msgs, msg_message("changebanner", "value",
u->faction->banner)); u->faction->banner));
@ -2404,9 +2404,9 @@ int password_cmd(unit * u, struct order *ord)
free(u->faction->passw); free(u->faction->passw);
if (!pwok) { if (!pwok) {
cmistake(u, ord, 283, MSG_EVENT); cmistake(u, ord, 283, MSG_EVENT);
u->faction->passw = strdup(itoa36(rng_int())); u->faction->passw = _strdup(itoa36(rng_int()));
} else { } else {
u->faction->passw = strdup(pwbuf); u->faction->passw = _strdup(pwbuf);
} }
fset(u->faction, FFL_OVERRIDE); fset(u->faction, FFL_OVERRIDE);
ADDMSG(&u->faction->msgs, msg_message("changepasswd", ADDMSG(&u->faction->msgs, msg_message("changepasswd",
@ -3582,7 +3582,7 @@ void new_units(void)
token = getstrtoken(); token = getstrtoken();
if (token && token[0]) { if (token && token[0]) {
name = strdup(token); name = _strdup(token);
} }
u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
if (name != NULL) if (name != NULL)
@ -4478,7 +4478,7 @@ static int warn_password(void)
} }
if (!pwok) { if (!pwok) {
free(f->passw); 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)); ADDMSG(&f->msgs, msg_message("illegal_password", "newpass", f->passw));
} }
f = f->next; f = f->next;

View File

@ -923,7 +923,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
e = e->next; e = e->next;
if (!e) { if (!e) {
e = calloc(sizeof(struct edge), 1); e = calloc(sizeof(struct edge), 1);
e->name = strdup(name); e->name = _strdup(name);
e->transparent = transparent; e->transparent = transparent;
e->next = edges; e->next = edges;
edges = e; edges = e;

View File

@ -75,7 +75,7 @@ alliance *makealliance(int id, const char *name)
al = calloc(1, sizeof(alliance)); al = calloc(1, sizeof(alliance));
al->id = id; al->id = id;
if (name) { if (name) {
al->name = strdup(name); al->name = _strdup(name);
} else { } else {
al->flags |= ALF_NON_ALLIED; al->flags |= ALF_NON_ALLIED;
} }
@ -518,7 +518,7 @@ void alliance_setname(alliance * self, const char *name)
{ {
free(self->name); free(self->name);
if (name) if (name)
self->name = strdup(name); self->name = _strdup(name);
else else
self->name = NULL; self->name = NULL;
} }

View File

@ -104,9 +104,9 @@ static int lc_read(struct attrib *a, void *owner, struct storage *store)
if (strcmp(lbuf, NULLSTRING) == 0) if (strcmp(lbuf, NULLSTRING) == 0)
data->param = NULL; data->param = NULL;
else else
data->param = strdup(lbuf); data->param = _strdup(lbuf);
} else { } else {
data->param = strdup(NULLSTRING); data->param = _strdup(NULLSTRING);
} }
if (result == 0 && !data->b) { if (result == 0 && !data->b) {
return AT_READ_FAIL; return AT_READ_FAIL;
@ -488,7 +488,7 @@ building *new_building(const struct building_type * btype, region * r,
} }
assert(bname); assert(bname);
slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b)); slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b));
b->name = strdup(bname); b->name = _strdup(bname);
return b; return b;
} }
@ -678,7 +678,7 @@ void building_setname(building * self, const char *name)
{ {
free(self->name); free(self->name);
if (name) if (name)
self->name = strdup(name); self->name = _strdup(name);
else else
self->name = NULL; 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)); attrib *a = a_add(&b->attribs, a_new(&at_building_action));
building_action *data = (building_action *) a->data.v; building_action *data = (building_action *) a->data.v;
data->b = b; data->b = b;
data->fname = strdup(fname); data->fname = _strdup(fname);
if (param) { if (param) {
data->param = strdup(param); data->param = _strdup(param);
} }
} }

View File

@ -19,7 +19,7 @@ static void test_register_building(CuTest * tc)
test_cleanup(); test_cleanup();
btype = (building_type *)calloc(sizeof(building_type), 1); btype = (building_type *)calloc(sizeof(building_type), 1);
btype->_name = strdup("herp"); btype->_name = _strdup("herp");
bt_register(btype); bt_register(btype);
CuAssertPtrNotNull(tc, bt_find("herp")); CuAssertPtrNotNull(tc, bt_find("herp"));

View File

@ -168,7 +168,7 @@ int AllianceAuto(void)
gamecookie = global.cookie; gamecookie = global.cookie;
value = 0; value = 0;
if (str != NULL) { if (str != NULL) {
char *sstr = strdup(str); char *sstr = _strdup(str);
char *tok = strtok(sstr, " "); char *tok = strtok(sstr, " ");
while (tok) { while (tok) {
value |= ally_flag(tok, -1); value |= ally_flag(tok, -1);
@ -195,7 +195,7 @@ int HelpMask(void)
gamecookie = global.cookie; gamecookie = global.cookie;
rule = 0; rule = 0;
if (str != NULL) { if (str != NULL) {
char *sstr = strdup(str); char *sstr = _strdup(str);
char *tok = strtok(sstr, " "); char *tok = strtok(sstr, " ");
while (tok) { while (tok) {
rule |= ally_flag(tok, -1); rule |= ally_flag(tok, -1);
@ -218,7 +218,7 @@ int AllianceRestricted(void)
gamecookie = global.cookie; gamecookie = global.cookie;
rule = 0; rule = 0;
if (str != NULL) { if (str != NULL) {
char *sstr = strdup(str); char *sstr = _strdup(str);
char *tok = strtok(sstr, " "); char *tok = strtok(sstr, " ");
while (tok) { while (tok) {
rule |= ally_flag(tok, -1); rule |= ally_flag(tok, -1);
@ -1542,7 +1542,7 @@ void addstrlist(strlist ** SP, const char *s)
{ {
strlist *slist = malloc(sizeof(strlist)); strlist *slist = malloc(sizeof(strlist));
slist->next = NULL; slist->next = NULL;
slist->s = strdup(s); slist->s = _strdup(s);
addlist(SP, slist); addlist(SP, slist);
} }
@ -2015,7 +2015,7 @@ static void init_locale(const struct locale *lang)
str = "gwyrrd illaun draig cerddor tybied"; str = "gwyrrd illaun draig cerddor tybied";
} }
sstr = strdup(str); sstr = _strdup(str);
tok = strtok(sstr, " "); tok = strtok(sstr, " ");
while (tok) { while (tok) {
for (i = 0; i != MAXMAGIETYP; ++i) { 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) { while (*p != NULL) {
if (strcmp((*p)->name, key) == 0) { if (strcmp((*p)->name, key) == 0) {
free((*p)->data); free((*p)->data);
(*p)->data = strdup(data); (*p)->data = _strdup(data);
return; return;
} }
p = &(*p)->next; p = &(*p)->next;
} }
*p = malloc(sizeof(param)); *p = malloc(sizeof(param));
(*p)->name = strdup(key); (*p)->name = _strdup(key);
(*p)->data = strdup(data); (*p)->data = _strdup(data);
(*p)->next = NULL; (*p)->next = NULL;
} }
@ -2262,7 +2262,7 @@ unsigned int getguard(const unit * u)
} }
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
char *strdup(const char *s) char *_strdup(const char *s)
{ {
return strcpy((char *)malloc(sizeof(char) * (strlen(s) + 1)), s); return strcpy((char *)malloc(sizeof(char) * (strlen(s) + 1)), s);
} }

View File

@ -46,7 +46,7 @@ equipment *create_equipment(const char *eqname)
int i = eq ? strcmp(eq->name, eqname) : 1; int i = eq ? strcmp(eq->name, eqname) : 1;
if (i > 0) { if (i > 0) {
eq = (equipment *)calloc(1, sizeof(equipment)); eq = (equipment *)calloc(1, sizeof(equipment));
eq->name = strdup(eqname); eq->name = _strdup(eqname);
eq->next = *eqp; eq->next = *eqp;
memset(eq->skills, 0, sizeof(eq->skills)); memset(eq->skills, 0, sizeof(eq->skills));
*eqp = eq; *eqp = eq;
@ -76,7 +76,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value)
{ {
if (eq != NULL) { if (eq != NULL) {
if (value != NULL) { if (value != NULL) {
eq->skills[sk] = strdup(value); eq->skills[sk] = _strdup(value);
} else if (eq->skills[sk]) { } else if (eq->skills[sk]) {
free(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) { if (idata == NULL) {
idata = (itemdata *) malloc(sizeof(itemdata)); idata = (itemdata *) malloc(sizeof(itemdata));
idata->itype = itype; idata->itype = itype;
idata->value = strdup(value); idata->value = _strdup(value);
idata->next = eq->items; idata->next = eq->items;
eq->items = idata; eq->items = idata;
} }

View File

@ -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); 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); faction_setpassword(f, password);
f->alliance_joindate = turn; f->alliance_joindate = turn;
@ -228,7 +228,7 @@ faction *addfaction(const char *email, const char *password,
fhash(f); fhash(f);
slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f)); slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f));
f->name = strdup(buf); f->name = _strdup(buf);
return f; return f;
} }
@ -455,7 +455,7 @@ void faction_setname(faction * self, const char *name)
{ {
free(self->name); free(self->name);
if (name) if (name)
self->name = strdup(name); self->name = _strdup(name);
} }
const char *faction_getemail(const faction * self) const char *faction_getemail(const faction * self)
@ -467,7 +467,7 @@ void faction_setemail(faction * self, const char *email)
{ {
free(self->email); free(self->email);
if (email) if (email)
self->email = strdup(email); self->email = _strdup(email);
} }
const char *faction_getbanner(const faction * self) const char *faction_getbanner(const faction * self)
@ -479,16 +479,16 @@ void faction_setbanner(faction * self, const char *banner)
{ {
free(self->banner); free(self->banner);
if (banner) if (banner)
self->banner = strdup(banner); self->banner = _strdup(banner);
} }
void faction_setpassword(faction * f, const char *passw) void faction_setpassword(faction * f, const char *passw)
{ {
free(f->passw); free(f->passw);
if (passw) if (passw)
f->passw = strdup(passw); f->passw = _strdup(passw);
else else
f->passw = strdup(itoa36(rng_int())); f->passw = _strdup(itoa36(rng_int()));
} }
bool valid_race(const struct faction *f, const struct race *rc) bool valid_race(const struct faction *f, const struct race *rc)

View File

@ -58,7 +58,7 @@ static group *new_group(faction * f, const char *name, int gid)
*gp = g; *gp = g;
maxgid = MAX(gid, maxgid); maxgid = MAX(gid, maxgid);
g->name = strdup(name); g->name = _strdup(name);
g->gid = gid; g->gid = gid;
g->nexthash = ghash[index]; g->nexthash = ghash[index];

View File

@ -158,9 +158,9 @@ resource_type *new_resourcetype(const char **names, const char **appearances,
rtype = (resource_type *)calloc(sizeof(resource_type), 1); rtype = (resource_type *)calloc(sizeof(resource_type), 1);
for (i = 0; i != 2; ++i) { for (i = 0; i != 2; ++i) {
rtype->_name[i] = strdup(names[i]); rtype->_name[i] = _strdup(names[i]);
if (appearances) if (appearances)
rtype->_appearance[i] = strdup(appearances[i]); rtype->_appearance[i] = _strdup(appearances[i]);
else else
rtype->_appearance[i] = NULL; rtype->_appearance[i] = NULL;
} }
@ -239,8 +239,8 @@ weapon_type *new_weapontype(item_type * itype,
wtype = calloc(sizeof(weapon_type), 1); wtype = calloc(sizeof(weapon_type), 1);
if (damage) { if (damage) {
wtype->damage[0] = strdup(damage[0]); wtype->damage[0] = _strdup(damage[0]);
wtype->damage[1] = strdup(damage[1]); wtype->damage[1] = _strdup(damage[1]);
} }
wtype->defmod = defmod; wtype->defmod = defmod;
wtype->flags |= wflags; wtype->flags |= wflags;

View File

@ -1807,7 +1807,7 @@ static int addparam_string(const char *const param[], spllprm ** spobjp)
spobj->flag = 0; spobj->flag = 0;
spobj->typ = SPP_STRING; spobj->typ = SPP_STRING;
spobj->data.xs = strdup(param[0]); spobj->data.xs = _strdup(param[0]);
return 1; return 1;
} }
@ -2682,7 +2682,7 @@ static castorder *cast_cmd(unit * u, order * ord)
size *= 2; size *= 2;
params = (char**)realloc(params, sizeof(char *) * size); params = (char**)realloc(params, sizeof(char *) * size);
} }
params[p++] = strdup(s); params[p++] = _strdup(s);
} }
params[p] = 0; params[p] = 0;
args = args =

View File

@ -139,7 +139,7 @@ static char *get_command(const order * ord, char *sbuffer, size_t size)
char *getcommand(const order * ord) char *getcommand(const order * ord)
{ {
char sbuffer[DISPLAYSIZE * 2]; 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) 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 + 1] = '\"';
data->_str[len + 2] = '\0'; data->_str[len + 2] = '\0';
} else { } else {
data->_str = strdup(skname); data->_str = _strdup(skname);
} }
data->_refcount = 1; 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 = (order_data *) malloc(sizeof(order_data));
data->_keyword = kwd; data->_keyword = kwd;
data->_lindex = lindex; data->_lindex = lindex;
data->_str = s ? strdup(s) : NULL; data->_str = s ? _strdup(s) : NULL;
data->_refcount = 1; data->_refcount = 1;
return data; return data;
} }

View File

@ -252,7 +252,7 @@ plane *create_new_plane(int id, const char *name, int minx, int maxx, int miny,
pl->next = NULL; pl->next = NULL;
pl->id = id; pl->id = id;
if (name) if (name)
pl->name = strdup(name); pl->name = _strdup(name);
pl->minx = minx; pl->minx = minx;
pl->maxx = maxx; pl->maxx = maxx;
pl->miny = miny; pl->miny = miny;

View File

@ -108,13 +108,13 @@ race *rc_new(const char *zName)
assert(strchr(zName, ' ') == NULL); assert(strchr(zName, ' ') == NULL);
} }
strcpy(zBuffer, zName); strcpy(zBuffer, zName);
rc->_name[0] = strdup(zBuffer); rc->_name[0] = _strdup(zBuffer);
sprintf(zBuffer, "%s_p", zName); sprintf(zBuffer, "%s_p", zName);
rc->_name[1] = strdup(zBuffer); rc->_name[1] = _strdup(zBuffer);
sprintf(zBuffer, "%s_d", zName); sprintf(zBuffer, "%s_d", zName);
rc->_name[2] = strdup(zBuffer); rc->_name[2] = _strdup(zBuffer);
sprintf(zBuffer, "%s_x", zName); sprintf(zBuffer, "%s_x", zName);
rc->_name[3] = strdup(zBuffer); rc->_name[3] = _strdup(zBuffer);
rc->precombatspell = NULL; rc->precombatspell = NULL;
rc->attack[0].type = AT_COMBATSPELL; rc->attack[0].type = AT_COMBATSPELL;
@ -172,7 +172,7 @@ extern void add_raceprefix(const char *prefix)
size *= 2; size *= 2;
race_prefixes = realloc(race_prefixes, size * sizeof(char *)); race_prefixes = realloc(race_prefixes, size * sizeof(char *));
} }
race_prefixes[next++] = strdup(prefix); race_prefixes[next++] = _strdup(prefix);
race_prefixes[next] = NULL; race_prefixes[next] = NULL;
} }

View File

@ -218,7 +218,7 @@ static dir_lookup *dir_name_lookup;
void register_special_direction(const char *name) void register_special_direction(const char *name)
{ {
struct locale *lang; struct locale *lang;
char *str = strdup(name); char *str = _strdup(name);
for (lang = locales; lang; lang = nextlocale(lang)) { for (lang = locales; lang; lang = nextlocale(lang)) {
void **tokens = get_translations(lang, UT_SPECDIR); 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); cstring_i(lbuf);
for (; dl; dl = dl->next) { for (; dl; dl = dl->next) {
if (strcmp(lbuf, dl->oldname) == 0) { if (strcmp(lbuf, dl->oldname) == 0) {
d->keyword = strdup(dl->name); d->keyword = _strdup(dl->name);
sprintf(lbuf, "%s_desc", d->keyword); sprintf(lbuf, "%s_desc", d->keyword);
d->desc = strdup(dl->name); d->desc = _strdup(dl->name);
break; break;
} }
} }
@ -335,8 +335,8 @@ attrib *create_special_direction(region * r, region * rt, int duration,
d->x = rt->x; d->x = rt->x;
d->y = rt->y; d->y = rt->y;
d->duration = duration; d->duration = duration;
d->desc = strdup(desc); d->desc = _strdup(desc);
d->keyword = strdup(keyword); d->keyword = _strdup(keyword);
return a; return a;
} }
@ -1557,7 +1557,7 @@ faction *update_owners(region * r)
void region_setinfo(struct region *r, const char *info) void region_setinfo(struct region *r, const char *info)
{ {
free(r->display); free(r->display);
r->display = info ? strdup(info) : 0; r->display = info ? _strdup(info) : 0;
} }
const char *region_getinfo(const region * r) const char *region_getinfo(const region * r)
@ -1569,7 +1569,7 @@ void region_setname(struct region *r, const char *name)
{ {
if (r->land) { if (r->land) {
free(r->land->name); free(r->land->name);
r->land->name = name ? strdup(name) : 0; r->land->name = name ? _strdup(name) : 0;
} }
} }

View File

@ -1788,7 +1788,7 @@ int reports(void)
static variant var_copy_string(variant x) 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; return x;
} }

View File

@ -212,7 +212,7 @@ struct rawmaterial_type *rmt_create(const struct resource_type *rtype,
const char *name) const char *name)
{ {
rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type)); rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type));
rmtype->name = strdup(name); rmtype->name = _strdup(name);
rmtype->rtype = rtype; rmtype->rtype = rtype;
rmtype->terraform = terraform_default; rmtype->terraform = terraform_default;
rmtype->update = NULL; rmtype->update = NULL;

View File

@ -1224,7 +1224,7 @@ faction *readfaction(struct storage * store)
if (store->version >= OVERRIDE_VERSION) { if (store->version >= OVERRIDE_VERSION) {
f->override = store->r_str(store); f->override = store->r_str(store);
} else { } else {
f->override = strdup(itoa36(rng_int())); f->override = _strdup(itoa36(rng_int()));
} }
store->r_str_buf(store, token, sizeof(token)); store->r_str_buf(store, token, sizeof(token));

View File

@ -185,7 +185,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
} }
assert(sname); assert(sname);
slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh)); slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh));
sh->name = strdup(buffer); sh->name = _strdup(buffer);
shash(sh); shash(sh);
if (r) { if (r) {
addlist(&r->ships, sh); addlist(&r->ships, sh);
@ -337,7 +337,7 @@ void ship_setname(ship * self, const char *name)
{ {
free(self->name); free(self->name);
if (name) if (name)
self->name = strdup(name); self->name = _strdup(name);
else else
self->name = NULL; self->name = NULL;
} }

View File

@ -19,7 +19,7 @@ static void test_register_ship(CuTest * tc)
test_cleanup(); test_cleanup();
stype = (ship_type *)calloc(sizeof(ship_type), 1); stype = (ship_type *)calloc(sizeof(ship_type), 1);
stype->name[0] = strdup("herp"); stype->name[0] = _strdup("herp");
st_register(stype); st_register(stype);
CuAssertPtrNotNull(tc, st_find("herp")); CuAssertPtrNotNull(tc, st_find("herp"));

View File

@ -64,7 +64,7 @@ spell * create_spell(const char * name, unsigned int id)
len = cb_new_kv(name, len, &sp, sizeof(sp), buffer); len = cb_new_kv(name, len, &sp, sizeof(sp), buffer);
if (cb_insert(&cb_spells, buffer, len)) { if (cb_insert(&cb_spells, buffer, len)) {
sp->id = id ? id : hashstring(name); sp->id = id ? id : hashstring(name);
sp->sname = strdup(name); sp->sname = _strdup(name);
add_spell(&spells, sp); add_spell(&spells, sp);
return sp; return sp;
} }

View File

@ -12,7 +12,7 @@
spellbook * create_spellbook(const char * name) spellbook * create_spellbook(const char * name)
{ {
spellbook *result = (spellbook *)malloc(sizeof(spellbook)); spellbook *result = (spellbook *)malloc(sizeof(spellbook));
result->name = name ? strdup(name) : 0; result->name = name ? _strdup(name) : 0;
result->spells = 0; result->spells = 0;
return result; return result;
} }

View File

@ -465,7 +465,7 @@ void usetprivate(unit * u, const char *str)
a = a_add(&u->attribs, a_new(&at_private)); a = a_add(&u->attribs, a_new(&at_private));
if (a->data.v) if (a->data.v)
free(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) { if (!dname) {
name_unit(u); name_unit(u);
} else { } else {
u->name = strdup(dname); u->name = _strdup(dname);
} }
if (creator) { if (creator) {
@ -1581,7 +1581,7 @@ void unit_setname(unit * u, const char *name)
{ {
free(u->name); free(u->name);
if (name) if (name)
u->name = strdup(name); u->name = _strdup(name);
else else
u->name = NULL; u->name = NULL;
} }
@ -1595,7 +1595,7 @@ void unit_setinfo(unit * u, const char *info)
{ {
free(u->display); free(u->display);
if (info) if (info)
u->display = strdup(info); u->display = _strdup(info);
else else
u->display = NULL; u->display = NULL;
} }

View File

@ -59,7 +59,7 @@ static building_type *bt_get_or_create(const char *name)
building_type *btype = bt_find(name); building_type *btype = bt_find(name);
if (btype == NULL) { if (btype == NULL) {
btype = calloc(sizeof(building_type), 1); btype = calloc(sizeof(building_type), 1);
btype->_name = strdup(name); btype->_name = _strdup(name);
bt_register(btype); bt_register(btype);
} }
return btype; return btype;
@ -403,7 +403,7 @@ static int parse_calendar(xmlDocPtr doc)
first_turn = xml_ivalue(calendar, "start", first_turn); first_turn = xml_ivalue(calendar, "start", first_turn);
if (propValue) { if (propValue) {
free(agename); free(agename);
agename = strdup(mkname("calendar", (const char *)propValue)); agename = _strdup(mkname("calendar", (const char *)propValue));
xmlFree(propValue); xmlFree(propValue);
} }
@ -421,7 +421,7 @@ static int parse_calendar(xmlDocPtr doc)
xmlNodePtr week = nsetWeeks->nodeTab[i]; xmlNodePtr week = nsetWeeks->nodeTab[i];
xmlChar *propValue = xmlGetProp(week, BAD_CAST "name"); xmlChar *propValue = xmlGetProp(week, BAD_CAST "name");
if (propValue) { 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); weeknames2[i] = malloc(strlen(weeknames[i]) + 3);
sprintf(weeknames2[i], "%s_d", weeknames[i]); sprintf(weeknames2[i], "%s_d", weeknames[i]);
xmlFree(propValue); xmlFree(propValue);
@ -444,7 +444,7 @@ static int parse_calendar(xmlDocPtr doc)
xmlChar *propValue = xmlGetProp(season, BAD_CAST "name"); xmlChar *propValue = xmlGetProp(season, BAD_CAST "name");
if (propValue) { if (propValue) {
seasonnames[i] = seasonnames[i] =
strdup(mkname("calendar", (const char *)propValue)); _strdup(mkname("calendar", (const char *)propValue));
xmlFree(propValue); xmlFree(propValue);
} }
} }
@ -473,7 +473,7 @@ static int parse_calendar(xmlDocPtr doc)
xmlFree(newyear); xmlFree(newyear);
newyear = NULL; newyear = NULL;
} }
monthnames[i] = strdup(mkname("calendar", (const char *)propValue)); monthnames[i] = _strdup(mkname("calendar", (const char *)propValue));
xmlFree(propValue); xmlFree(propValue);
} }
for (j = 0; j != seasons; ++j) { for (j = 0; j != seasons; ++j) {
@ -542,7 +542,7 @@ static int parse_ships(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL); assert(propValue != NULL);
st->name[0] = strdup((const char *)propValue); st->name[0] = _strdup((const char *)propValue);
st->name[1] = st->name[1] =
strcat(strcpy(malloc(strlen(st->name[0]) + 3), st->name[0]), "_a"); strcat(strcpy(malloc(strlen(st->name[0]) + 3), st->name[0]), "_a");
xmlFree(propValue); xmlFree(propValue);
@ -746,7 +746,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
xmlFree(propValue); xmlFree(propValue);
propValue = xmlGetProp(node, BAD_CAST "value"); 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) if (k == 0)
wtype->damage[1 - pos] = wtype->damage[pos]; wtype->damage[1 - pos] = wtype->damage[pos];
xmlFree(propValue); xmlFree(propValue);
@ -1034,7 +1034,7 @@ static int parse_resources(xmlDocPtr doc)
/* dependency from another item, was created earlier */ /* dependency from another item, was created earlier */
rtype->flags |= flags; rtype->flags |= flags;
if (appearance) { if (appearance) {
rtype->_appearance[0] = strdup((const char *)appearance); rtype->_appearance[0] = _strdup((const char *)appearance);
rtype->_appearance[1] = appearancep; rtype->_appearance[1] = appearancep;
free(appearancep); free(appearancep);
} }
@ -1547,13 +1547,13 @@ static int parse_spells(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "parameters"); propValue = xmlGetProp(node, BAD_CAST "parameters");
if (propValue) { if (propValue) {
sp->parameter = strdup((const char *)propValue); sp->parameter = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
} }
propValue = xmlGetProp(node, BAD_CAST "syntax"); propValue = xmlGetProp(node, BAD_CAST "syntax");
if (propValue) { if (propValue) {
sp->syntax = strdup((const char *)propValue); sp->syntax = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
} }
#ifdef TODO /* no longer need it, spellbooks! */ #ifdef TODO /* no longer need it, spellbooks! */
@ -1730,7 +1730,7 @@ static int parse_races(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "damage"); propValue = xmlGetProp(node, BAD_CAST "damage");
assert(propValue != NULL); assert(propValue != NULL);
rc->def_damage = strdup((const char *)propValue); rc->def_damage = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
rc->magres = (float)xml_fvalue(node, "magres", 0.0); 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"); propValue = xmlGetProp(node, BAD_CAST "damage");
if (propValue != NULL) { if (propValue != NULL) {
attack->data.dice = strdup((const char *)propValue); attack->data.dice = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
} else { } else {
attack->data.sp = xml_spell(node, "spell"); attack->data.sp = xml_spell(node, "spell");
@ -1997,7 +1997,7 @@ static int parse_terrains(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL); assert(propValue != NULL);
terrain->_name = strdup((const char *)propValue); terrain->_name = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
terrain->max_road = (short)xml_ivalue(node, "road", 0); 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"); propValue = xmlGetProp(nodeProd, BAD_CAST "level");
assert(propValue); assert(propValue);
terrain->production[k].startlevel = strdup((const char *)propValue); terrain->production[k].startlevel = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
propValue = xmlGetProp(nodeProd, BAD_CAST "base"); propValue = xmlGetProp(nodeProd, BAD_CAST "base");
assert(propValue); assert(propValue);
terrain->production[k].base = strdup((const char *)propValue); terrain->production[k].base = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
propValue = xmlGetProp(nodeProd, BAD_CAST "div"); propValue = xmlGetProp(nodeProd, BAD_CAST "div");
assert(propValue); assert(propValue);
terrain->production[k].divisor = strdup((const char *)propValue); terrain->production[k].divisor = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
terrain->production[k].chance = terrain->production[k].chance =
@ -2145,7 +2145,7 @@ static int parse_messages(xmlDocPtr doc)
(const char *)propType); (const char *)propType);
xmlFree(propName); xmlFree(propName);
xmlFree(propType); xmlFree(propType);
argv[k] = strdup(zBuffer); argv[k] = _strdup(zBuffer);
} }
argv[result->nodesetval->nodeNr] = NULL; argv[result->nodesetval->nodeNr] = NULL;
} }
@ -2321,7 +2321,7 @@ static int parse_main(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
if (propValue != NULL) { if (propValue != NULL) {
global.gamename = strdup((const char *)propValue); global.gamename = _strdup((const char *)propValue);
xmlFree(propValue); xmlFree(propValue);
} }

View File

@ -275,9 +275,9 @@ static void make_temple(region * r)
b = new_building(btype, r, NULL); b = new_building(btype, r, NULL);
b->size = btype->maxsize; b->size = btype->maxsize;
b->name = strdup("Igjarjuk's Tempel der Schreie"); b->name = _strdup("Igjarjuk's Tempel der Schreie");
b->display = b->display =
strdup _strdup
("Ein Schrein aus spitzen Knochen und lodernden Flammen, gewidmet dem Wyrm der Wyrme"); ("Ein Schrein aus spitzen Knochen und lodernden Flammen, gewidmet dem Wyrm der Wyrme");
a_add(&b->attribs, a_new(&at_hurting))->data.v = b; 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) { if (!f) {
f = calloc(1, sizeof(faction)); f = calloc(1, sizeof(faction));
f->banner = strdup("Sie dienen dem großen Wyrm"); f->banner = _strdup("Sie dienen dem großen Wyrm");
f->passw = strdup(itoa36(rng_int())); f->passw = _strdup(itoa36(rng_int()));
f->override = strdup(itoa36(rng_int())); f->override = _strdup(itoa36(rng_int()));
set_email(&f->email, "igjarjuk@eressea.de"); set_email(&f->email, "igjarjuk@eressea.de");
f->name = strdup("Igjarjuks Kundschafter"); f->name = _strdup("Igjarjuks Kundschafter");
f->race = new_race[RC_ILLUSION]; f->race = new_race[RC_ILLUSION];
f->age = turn; f->age = turn;
f->locale = find_locale("de"); f->locale = find_locale("de");
@ -480,9 +480,9 @@ static void init_volcano(void)
terraform(arena_center, T_VOLCANO_SMOKING); terraform(arena_center, T_VOLCANO_SMOKING);
b = new_building(bt_find("caldera"), r, NULL); b = new_building(bt_find("caldera"), r, NULL);
b->size = 1; b->size = 1;
b->name = strdup("Igjarjuk's Schlund"); b->name = _strdup("Igjarjuk's Schlund");
b->display = b->display =
strdup _strdup
("Feurige Lava fließt aus dem Krater des großen Vulkans. Alles wird von ihr verschlungen."); ("Feurige Lava fließt aus dem Krater des großen Vulkans. Alles wird von ihr verschlungen.");
add_trigger(&b->attribs, "timer", trigger_caldera(b)); add_trigger(&b->attribs, "timer", trigger_caldera(b));
tt_register(&tt_caldera); tt_register(&tt_caldera);

View File

@ -267,7 +267,7 @@ newfaction *read_newfactions(const char *filename)
log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email); log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
continue; continue;
} }
nf->password = strdup(password); nf->password = _strdup(password);
nf->race = rc_find(race); nf->race = rc_find(race);
nf->subscription = subscription; nf->subscription = subscription;
if (alliances != NULL) { if (alliances != NULL) {

View File

@ -662,10 +662,10 @@ faction *gm_addfaction(const char *email, plane * p, region * r)
/* GM faction */ /* GM faction */
a_add(&f->attribs, make_key(atoi36("quest"))); a_add(&f->attribs, make_key(atoi36("quest")));
f->banner = strdup("quest faction"); f->banner = _strdup("quest faction");
f->name = strdup("quest faction"); f->name = _strdup("quest faction");
f->passw = strdup(itoa36(rng_int())); f->passw = _strdup(itoa36(rng_int()));
f->override = strdup(itoa36(rng_int())); f->override = _strdup(itoa36(rng_int()));
if (set_email(&f->email, email) != 0) { if (set_email(&f->email, email) != 0) {
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email); log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
} }

View File

@ -247,12 +247,6 @@ typedef struct _stat stat_type;
#define TOLUA_CAST (char*) #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)
# if defined(HAVE_STRDUP) # if defined(HAVE_STRDUP)
# define _strdup(s) strdup(s) # define _strdup(s) strdup(s)

View File

@ -118,7 +118,7 @@ test_create_terrain(const char * name, unsigned int flags)
assert(!get_terrain(name)); assert(!get_terrain(name));
t = (terrain_type*)calloc(1, sizeof(terrain_type)); t = (terrain_type*)calloc(1, sizeof(terrain_type));
t->_name = strdup(name); t->_name = _strdup(name);
t->flags = flags; t->flags = flags;
register_terrain(t); register_terrain(t);
return 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 * test_create_shiptype(const char ** names)
{ {
ship_type * stype = (ship_type*)calloc(sizeof(ship_type), 1); ship_type * stype = (ship_type*)calloc(sizeof(ship_type), 1);
stype->name[0] = strdup(names[0]); stype->name[0] = _strdup(names[0]);
stype->name[1] = strdup(names[1]); stype->name[1] = _strdup(names[1]);
locale_setstring(default_locale, names[0], names[0]); locale_setstring(default_locale, names[0], names[0]);
st_register(stype); st_register(stype);
return 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); building_type * btype = (building_type*)calloc(sizeof(building_type), 1);
btype->flags = BTF_NAMECHANGE; btype->flags = BTF_NAMECHANGE;
btype->_name = strdup(name); btype->_name = _strdup(name);
locale_setstring(default_locale, name, name); locale_setstring(default_locale, name, name);
bt_register(btype); bt_register(btype);
return btype; return btype;

View File

@ -85,7 +85,7 @@ static void do_shock(unit * u, const char *reason)
} }
if (u->faction != NULL) { if (u->faction != NULL) {
ADDMSG(&u->faction->msgs, msg_message("shock", ADDMSG(&u->faction->msgs, msg_message("shock",
"mage reason", u, strdup(reason))); "mage reason", u, _strdup(reason)));
} }
} }

View File

@ -94,7 +94,7 @@ static int unitmessage_read(trigger * t, struct storage *store)
td->string = store->r_tok(store); td->string = store->r_tok(store);
td->type = store->r_int(store); td->type = store->r_int(store);
td->level = store->r_int(store); td->level = store->r_int(store);
td->string = strdup(zText); td->string = _strdup(zText);
if (result == 0 && td->target == NULL) { if (result == 0 && td->target == NULL) {
return AT_READ_FAIL; return AT_READ_FAIL;
@ -117,7 +117,7 @@ trigger *trigger_unitmessage(unit * target, const char *string, int type,
trigger *t = t_new(&tt_unitmessage); trigger *t = t_new(&tt_unitmessage);
unitmessage_data *td = (unitmessage_data *) t->data.v; unitmessage_data *td = (unitmessage_data *) t->data.v;
td->target = target; td->target = target;
td->string = strdup(string); td->string = _strdup(string);
td->type = type; td->type = type;
td->level = level; td->level = level;
return t; return t;

View File

@ -147,7 +147,7 @@ static int read_handler(attrib * a, void *owner, struct storage *store)
handler_info *hi = (handler_info *) a->data.v; handler_info *hi = (handler_info *) a->data.v;
store->r_tok_buf(store, zText, sizeof(zText)); store->r_tok_buf(store, zText, sizeof(zText));
hi->event = strdup(zText); hi->event = _strdup(zText);
read_triggers(store, &hi->triggers); read_triggers(store, &hi->triggers);
if (hi->triggers != NULL) { if (hi->triggers != NULL) {
return AT_READ_OK; 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) { if (a == NULL || a->type != &at_eventhandler) {
a = a_add(ap, a_new(&at_eventhandler)); a = a_add(ap, a_new(&at_eventhandler));
td = (handler_info *) a->data.v; td = (handler_info *) a->data.v;
td->event = strdup(eventname); td->event = _strdup(eventname);
} }
tp = &td->triggers; tp = &td->triggers;
while (*tp) while (*tp)

View File

@ -131,7 +131,7 @@ int set_email(char **pemail, const char *newmail)
free(*pemail); free(*pemail);
*pemail = 0; *pemail = 0;
if (newmail) { if (newmail) {
*pemail = strdup(newmail); *pemail = _strdup(newmail);
} }
return 0; return 0;
} }

View File

@ -68,7 +68,7 @@ locale *make_locale(const char *name)
} }
l->hashkey = hkey; l->hashkey = hkey;
l->name = strdup(name); l->name = _strdup(name);
l->next = NULL; l->next = NULL;
l->index = nextlocaleindex++; l->index = nextlocaleindex++;
assert(nextlocaleindex <= MAXLOCALES); assert(nextlocaleindex <= MAXLOCALES);
@ -181,8 +181,8 @@ void locale_setstring(locale * lang, const char *key, const char *value)
find->nexthash = lang->strings[id]; find->nexthash = lang->strings[id];
lang->strings[id] = find; lang->strings[id] = find;
find->hashkey = hkey; find->hashkey = hkey;
find->key = strdup(key); find->key = _strdup(key);
find->str = strdup(value); find->str = _strdup(value);
} else { } else {
if (strcmp(find->str, value) != 0) { if (strcmp(find->str, value) != 0) {
log_error("duplicate translation '%s' for key %s\n", value, key); log_error("duplicate translation '%s' for key %s\n", value, key);

View File

@ -26,7 +26,7 @@ insert_selection(list_selection ** p_sel, list_selection * prev,
const char *str, void *payload) const char *str, void *payload)
{ {
list_selection *sel = calloc(sizeof(list_selection), 1); list_selection *sel = calloc(sizeof(list_selection), 1);
sel->str = strdup(str); sel->str = _strdup(str);
sel->data = payload; sel->data = payload;
if (*p_sel) { if (*p_sel) {
list_selection *s; list_selection *s;

View File

@ -45,7 +45,7 @@ message_type *mt_new(const char *name, const char *args[])
if (args != NULL) if (args != NULL)
for (nparameters = 0; args[nparameters]; ++nparameters) ; for (nparameters = 0; args[nparameters]; ++nparameters) ;
mtype->name = strdup(name); mtype->name = _strdup(name);
mtype->nparameters = nparameters; mtype->nparameters = nparameters;
if (nparameters > 0) { if (nparameters > 0) {
mtype->pnames = (const char **)malloc(sizeof(char *) * nparameters); 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 *x = args[i];
const char *spos = strchr(x, ':'); const char *spos = strchr(x, ':');
if (spos == NULL) { if (spos == NULL) {
mtype->pnames[i] = strdup(x); mtype->pnames[i] = _strdup(x);
mtype->types[i] = NULL; mtype->types[i] = NULL;
} else { } else {
char *cp = strncpy((char *)malloc(spos - x + 1), x, spos - x); char *cp = strncpy((char *)malloc(spos - x + 1), x, spos - x);

View File

@ -91,7 +91,7 @@ const nrsection *section_add(const char *name)
} }
if (!*mcp) { if (!*mcp) {
nrsection *mc = calloc(sizeof(nrsection), 1); nrsection *mc = calloc(sizeof(nrsection), 1);
mc->name = strdup(name); mc->name = _strdup(name);
*mcp = mc; *mcp = mc;
} }
return *mcp; return *mcp;
@ -128,14 +128,14 @@ nrt_register(const struct message_type *mtype, const struct locale *lang,
nrt->section = NULL; nrt->section = NULL;
nrtypes[hash] = nrt; nrtypes[hash] = nrt;
assert(string && *string); assert(string && *string);
nrt->string = strdup(string); nrt->string = _strdup(string);
*c = '\0'; *c = '\0';
for (i = 0; i != mtype->nparameters; ++i) { for (i = 0; i != mtype->nparameters; ++i) {
if (i != 0) if (i != 0)
*c++ = ' '; *c++ = ' ';
c += strlen(strcpy(c, mtype->pnames[i])); c += strlen(strcpy(c, mtype->pnames[i]));
} }
nrt->vars = strdup(zNames); nrt->vars = _strdup(zNames);
} }
} }

View File

@ -32,7 +32,7 @@ void sql_init(const char *filename)
{ {
if (sqlfilename != NULL) if (sqlfilename != NULL)
free(sqlfilename); free(sqlfilename);
sqlfilename = strdup(filename); sqlfilename = _strdup(filename);
} }
void _sql_print(const char *format, ...) void _sql_print(const char *format, ...)