aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/lcDB.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/X11/lcDB.c')
-rw-r--r--nx-X11/lib/X11/lcDB.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/nx-X11/lib/X11/lcDB.c b/nx-X11/lib/X11/lcDB.c
index 1353acfe3..1111ec955 100644
--- a/nx-X11/lib/X11/lcDB.c
+++ b/nx-X11/lib/X11/lcDB.c
@@ -165,7 +165,7 @@ init_parse_info (void)
int size;
if (!allocated) {
bzero(&parse_info, sizeof(DBParseInfo));
- parse_info.buf = (char *)Xmalloc(BUFSIZE);
+ parse_info.buf = Xmalloc(BUFSIZE);
parse_info.bufMaxSize = BUFSIZE;
allocated = 1;
return;
@@ -196,7 +196,7 @@ clear_parse_info (void)
if (*parse_info.value) {
Xfree(*parse_info.value);
}
- Xfree((char *)parse_info.value);
+ Xfree(parse_info.value);
}
ptr = parse_info.buf;
size = parse_info.bufMaxSize;
@@ -210,11 +210,12 @@ realloc_parse_info(
int len)
{
char *p;
+ int newsize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
- parse_info.bufMaxSize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
- p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize);
+ p = Xrealloc(parse_info.buf, newsize);
if (p == NULL)
return False;
+ parse_info.bufMaxSize = newsize;
parse_info.buf = p;
return True;
@@ -247,9 +248,9 @@ realloc_line(
char *str = line->str;
if (str != NULL) {
- str = (char *)Xrealloc(str, size);
+ str = Xrealloc(str, size);
} else {
- str = (char *)Xmalloc(size);
+ str = Xmalloc(size);
}
if (str == NULL) {
/* malloc error */
@@ -485,7 +486,7 @@ append_value_list (void)
}
if (value_list == (char **)NULL) {
- value_list = (char **)Xmalloc(sizeof(char *) * 2);
+ value_list = Xmalloc(sizeof(char *) * 2);
*value_list = NULL;
} else {
char **prev_list = value_list;
@@ -501,11 +502,11 @@ append_value_list (void)
value = *value_list;
if (value == NULL) {
- value = (char *)Xmalloc(value_len + len + 1);
+ value = Xmalloc(value_len + len + 1);
} else {
char *prev_value = value;
- value = (char *)Xrealloc(value, value_len + len + 1);
+ value = Xrealloc(value, value_len + len + 1);
if (value == NULL) {
Xfree(prev_value);
}
@@ -591,26 +592,23 @@ store_to_database(
goto err;
}
- new = (Database)Xmalloc(sizeof(DatabaseRec));
+ new = Xcalloc(1, sizeof(DatabaseRec));
if (new == (Database)NULL) {
goto err;
}
- bzero(new, sizeof(DatabaseRec));
- new->category = (char *)Xmalloc(strlen(parse_info.category) + 1);
+ new->category = strdup(parse_info.category);
if (new->category == NULL) {
goto err;
}
- strcpy(new->category, parse_info.category);
if (! construct_name(name, sizeof(name))) {
goto err;
}
- new->name = (char *)Xmalloc(strlen(name) + 1);
+ new->name = strdup(name);
if (new->name == NULL) {
goto err;
}
- strcpy(new->name, name);
new->next = *db;
new->value = parse_info.value;
new->value_num = parse_info.value_num;
@@ -944,10 +942,9 @@ f_default(
case S_NULL:
if (parse_info.category != NULL)
goto err;
- p = (char *)Xmalloc(strlen(wordp) + 1);
+ p = strdup(wordp);
if (p == NULL)
goto err;
- strcpy(p, wordp);
parse_info.category = p;
parse_info.pre_state = S_CATEGORY;
break;
@@ -961,10 +958,9 @@ f_default(
break;
}
}
- p = (char *)Xmalloc(strlen(wordp) + 1);
+ p = strdup(wordp);
if (p == NULL)
goto err;
- strcpy(p, wordp);
if (parse_info.name[parse_info.nest_depth] != NULL) {
Xfree(parse_info.name[parse_info.nest_depth]);
}
@@ -1037,10 +1033,10 @@ DestroyDatabase(
if (*p->value != NULL) {
Xfree(*p->value);
}
- Xfree((char *)p->value);
+ Xfree(p->value);
}
db = p->next;
- Xfree((char *)p);
+ Xfree(p);
p = db;
}
}
@@ -1253,7 +1249,7 @@ _XlcDestroyLocaleDataBase(
if (p->lc_db == lc_db) {
if ((-- p->ref_count) < 1) {
if (p->lc_db != (XlcDatabase)NULL) {
- Xfree((char *)p->lc_db);
+ Xfree(p->lc_db);
}
DestroyDatabase(p->database);
if (prev == (XlcDatabaseList)NULL) {
@@ -1309,17 +1305,16 @@ _XlcCreateLocaleDataBase(
return (XPointer)NULL;
}
n = CountDatabase(database);
- lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1));
+ lc_db = Xcalloc(n + 1, sizeof(XlcDatabaseRec));
if (lc_db == (XlcDatabase)NULL)
goto err;
- bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1));
for (p = database, i = 0; p && i < n; p = p->next, ++i) {
lc_db[i].category_q = XrmStringToQuark(p->category);
lc_db[i].name_q = XrmStringToQuark(p->name);
lc_db[i].db = p;
}
- new = (XlcDatabaseList)Xmalloc(sizeof(XlcDatabaseListRec));
+ new = Xmalloc(sizeof(XlcDatabaseListRec));
if (new == (XlcDatabaseList)NULL) {
goto err;
}
@@ -1336,7 +1331,7 @@ _XlcCreateLocaleDataBase(
err:
DestroyDatabase(database);
if (lc_db != (XlcDatabase)NULL) {
- Xfree((char *)lc_db);
+ Xfree(lc_db);
}
Xfree (name);
return (XPointer)NULL;