mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-08 04:28:04 +02:00
Convert src/xlibi18n to use reallocarray()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
parent
336c1e7a50
commit
ba7f7cc783
7 changed files with 31 additions and 23 deletions
|
|
@ -66,6 +66,7 @@ from The Open Group.
|
|||
#endif
|
||||
#include "Xlibint.h"
|
||||
#include "Xlcint.h"
|
||||
#include "reallocarray.h"
|
||||
|
||||
static int
|
||||
_XIMNestedListToNestedList(
|
||||
|
|
@ -128,7 +129,7 @@ _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
|
|||
return;
|
||||
}
|
||||
|
||||
args = Xmalloc(((unsigned)max_count + 1) * sizeof(XIMArg));
|
||||
args = Xmallocarray((unsigned)max_count + 1, sizeof(XIMArg));
|
||||
*args_return = args;
|
||||
if (!args) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ Sun Microsystems, Inc. or its licensors is granted.
|
|||
#include "Xlibint.h"
|
||||
#include "Xlcint.h"
|
||||
#include "XlcGeneric.h"
|
||||
#include "reallocarray.h"
|
||||
|
||||
#ifndef MAXINT
|
||||
#define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1))
|
||||
|
|
@ -266,7 +267,7 @@ _GetIMValues(
|
|||
*(XIMStyles **)p->value = styles;
|
||||
styles->count_styles = 1;
|
||||
styles->supported_styles =
|
||||
Xmalloc(styles->count_styles * sizeof(XIMStyle));
|
||||
Xmallocarray(styles->count_styles, sizeof(XIMStyle));
|
||||
styles->supported_styles[0] = (XIMPreeditNone | XIMStatusNone);
|
||||
} else {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ Sun Microsystems, Inc. or its licensors is granted.
|
|||
#include "Xlibint.h"
|
||||
#include "XlcPublic.h"
|
||||
#include "XlcPubI.h"
|
||||
#include "reallocarray.h"
|
||||
|
||||
#define XI18N_DLREL 2
|
||||
|
||||
|
|
@ -185,7 +186,7 @@ resolve_object(char *path, const char *lc_name)
|
|||
|
||||
if (lc_len == 0) { /* True only for the 1st time */
|
||||
lc_len = OBJECT_INIT_LEN;
|
||||
xi18n_objects_list = Xmalloc(sizeof(XI18NObjectsListRec) * lc_len);
|
||||
xi18n_objects_list = Xmallocarray(lc_len, sizeof(XI18NObjectsListRec));
|
||||
if (!xi18n_objects_list) return;
|
||||
}
|
||||
snprintf(filename, sizeof(filename), "%s/%s", path, "XI18N_OBJS");
|
||||
|
|
@ -207,8 +208,9 @@ resolve_object(char *path, const char *lc_name)
|
|||
|
||||
if (lc_count == lc_len) {
|
||||
int new_len = lc_len + OBJECT_INC_LEN;
|
||||
XI18NObjectsListRec *tmp = Xrealloc(xi18n_objects_list,
|
||||
sizeof(XI18NObjectsListRec) * new_len);
|
||||
XI18NObjectsListRec *tmp =
|
||||
Xreallocarray(xi18n_objects_list, new_len,
|
||||
sizeof(XI18NObjectsListRec));
|
||||
if (tmp == NULL)
|
||||
goto done;
|
||||
xi18n_objects_list = tmp;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include <X11/Xresource.h>
|
||||
#include "Xlibint.h"
|
||||
#include "XlcPubI.h"
|
||||
#include "reallocarray.h"
|
||||
|
||||
#else /* NOT_X_ENV */
|
||||
|
||||
|
|
@ -492,7 +493,7 @@ append_value_list (void)
|
|||
char **prev_list = value_list;
|
||||
|
||||
value_list = (char **)
|
||||
Xrealloc(value_list, sizeof(char *) * (value_num + 2));
|
||||
Xreallocarray(value_list, value_num + 2, sizeof(char *));
|
||||
if (value_list == NULL) {
|
||||
Xfree(prev_list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <stdio.h>
|
||||
#include "Xlibint.h"
|
||||
#include "XlcGeneric.h"
|
||||
#include "reallocarray.h"
|
||||
|
||||
static XLCd create (const char *name, XLCdMethods methods);
|
||||
static Bool initialize (XLCd lcd);
|
||||
|
|
@ -157,8 +158,8 @@ add_charset(
|
|||
int num;
|
||||
|
||||
if ((num = codeset->num_charsets))
|
||||
new_list = Xrealloc(codeset->charset_list,
|
||||
(num + 1) * sizeof(XlcCharSet));
|
||||
new_list = Xreallocarray(codeset->charset_list,
|
||||
num + 1, sizeof(XlcCharSet));
|
||||
else
|
||||
new_list = Xmalloc(sizeof(XlcCharSet));
|
||||
|
||||
|
|
@ -184,8 +185,8 @@ add_codeset(
|
|||
return NULL;
|
||||
|
||||
if ((num = gen->codeset_num))
|
||||
new_list = Xrealloc(gen->codeset_list,
|
||||
(num + 1) * sizeof(CodeSet));
|
||||
new_list = Xreallocarray(gen->codeset_list,
|
||||
num + 1, sizeof(CodeSet));
|
||||
else
|
||||
new_list = Xmalloc(sizeof(CodeSet));
|
||||
|
||||
|
|
@ -231,8 +232,8 @@ add_parse_list(
|
|||
}
|
||||
|
||||
if ((num = gen->mb_parse_list_num))
|
||||
new_list = Xrealloc(gen->mb_parse_list,
|
||||
(num + 2) * sizeof(ParseInfo));
|
||||
new_list = Xreallocarray(gen->mb_parse_list,
|
||||
num + 2, sizeof(ParseInfo));
|
||||
else {
|
||||
new_list = Xmalloc(2 * sizeof(ParseInfo));
|
||||
}
|
||||
|
|
@ -350,7 +351,7 @@ _XlcParse_scopemaps(
|
|||
const char *str_sc;
|
||||
|
||||
num = count_scopemap(str);
|
||||
scope = Xmalloc(num * sizeof(FontScopeRec));
|
||||
scope = Xmallocarray(num, sizeof(FontScopeRec));
|
||||
if (scope == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -535,8 +536,8 @@ add_conversion(
|
|||
int num;
|
||||
|
||||
if ((num = gen->segment_conv_num) > 0) {
|
||||
new_list = Xrealloc(gen->segment_conv,
|
||||
(num + 1) * sizeof(SegConvRec));
|
||||
new_list = Xreallocarray(gen->segment_conv,
|
||||
num + 1, sizeof(SegConvRec));
|
||||
} else {
|
||||
new_list = Xmalloc(sizeof(SegConvRec));
|
||||
}
|
||||
|
|
@ -667,7 +668,7 @@ create_ctextseg(
|
|||
ret->side = XlcGLGR;
|
||||
strcpy(cset_name,ret->name);
|
||||
}
|
||||
ret->area = Xmalloc((num - 1)*sizeof(FontScopeRec));
|
||||
ret->area = Xmallocarray(num - 1, sizeof(FontScopeRec));
|
||||
if (ret->area == NULL) {
|
||||
Xfree (cset_name);
|
||||
Xfree (ret->name);
|
||||
|
|
@ -870,8 +871,8 @@ load_generic(
|
|||
codeset->byteM = NULL;
|
||||
break ;
|
||||
}
|
||||
codeset->byteM = Xmalloc(
|
||||
(codeset->length)*sizeof(ByteInfoListRec));
|
||||
codeset->byteM = Xmallocarray(codeset->length,
|
||||
sizeof(ByteInfoListRec));
|
||||
if (codeset->byteM == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
|
@ -882,7 +883,7 @@ load_generic(
|
|||
(codeset->byteM)[M-1].M = M;
|
||||
(codeset->byteM)[M-1].byteinfo_num = num;
|
||||
(codeset->byteM)[M-1].byteinfo =
|
||||
Xmalloc(num * sizeof(ByteInfoRec));
|
||||
Xmallocarray(num, sizeof(ByteInfoRec));
|
||||
for (ii = 0 ; ii < num ; ii++) {
|
||||
tmpb = (codeset->byteM)[M-1].byteinfo ;
|
||||
/* default 0x00 - 0xff */
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "XlcPubI.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include "reallocarray.h"
|
||||
|
||||
static XPointer *
|
||||
alloc_list(
|
||||
|
|
@ -40,11 +41,11 @@ alloc_list(
|
|||
if (is_wide_char) {
|
||||
wchar_t **wstr_list;
|
||||
|
||||
wstr_list = Xmalloc(count * sizeof(wchar_t *));
|
||||
wstr_list = Xmallocarray(count, sizeof(wchar_t *));
|
||||
if (wstr_list == NULL)
|
||||
return (XPointer *) NULL;
|
||||
|
||||
*wstr_list = Xmalloc(nitems * sizeof(wchar_t));
|
||||
*wstr_list = Xmallocarray(nitems, sizeof(wchar_t));
|
||||
if (*wstr_list == NULL) {
|
||||
Xfree(wstr_list);
|
||||
return (XPointer *) NULL;
|
||||
|
|
@ -54,7 +55,7 @@ alloc_list(
|
|||
} else {
|
||||
char **str_list;
|
||||
|
||||
str_list = Xmalloc(count * sizeof(char *));
|
||||
str_list = Xmallocarray(count, sizeof(char *));
|
||||
if (str_list == NULL)
|
||||
return (XPointer *) NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ from The Open Group.
|
|||
#endif
|
||||
#include <X11/Xutil.h>
|
||||
#include "XlcPubI.h"
|
||||
#include "reallocarray.h"
|
||||
|
||||
#ifdef XTHREADS
|
||||
LockInfoPtr _Xi18n_lock;
|
||||
|
|
@ -564,7 +565,7 @@ _XlcVaToArgList(
|
|||
{
|
||||
XlcArgList args;
|
||||
|
||||
*args_ret = args = Xmalloc(sizeof(XlcArg) * count);
|
||||
*args_ret = args = Xmallocarray(count, sizeof(XlcArg));
|
||||
if (args == (XlcArgList) NULL)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue