[Pkg-jed-commit] [SCM] Debian packaging of JED branch, upstream-fixes, updated. 456f22085fafbdc310fed2c33a99d3d5c7476d36
Jörg Sommer
joerg at alea.gnuu.de
Thu Nov 19 13:01:19 UTC 2009
The following commit has been merged in the upstream-fixes branch:
commit e87ddd7262a57e303ec52fb7c080bba6e27a7794
Author: Jörg Sommer <joerg at alea.gnuu.de>
Date: Sun Aug 24 18:34:57 2008 +0200
Use intermediate void* pointer for SLmalloc() return values
The cast from char* to any other pointer type might increases required
alignment of target type. This causes problems on some architectures
(like alpha).
Fix it by saving the result of SLmalloc() and SLrealloc() to a void*
pointer and then copy it to the target variable.
diff --git a/src/abbrev.c b/src/abbrev.c
index b8400a2..25349cc 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -256,7 +256,11 @@ void define_abbrev (char *table, char *abbrev, char *expans) /*{{{*/
unsigned int max_len = tbl->max_len + 32;
/* SLrealloc handles NULL via malloc */
- if (NULL == (a = (Abbrev_Type *) SLrealloc ((char *) a, max_len * sizeof (Abbrev_Type))))
+ {
+ void *tmp_ptr = SLrealloc ((char *) a, max_len * sizeof (Abbrev_Type));
+ a = tmp_ptr;
+ }
+ if (NULL == a)
return;
tbl->abbrevs = a;
diff --git a/src/buffer.c b/src/buffer.c
index 7205afd..47798a1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -692,7 +692,11 @@ static Line *create_line_from_bunch(void) /*{{{*/
/* failed so now malloc new bunch */
- if (NULL == (b = (Bunch_Lines_Type *) SLmalloc (sizeof(Bunch_Lines_Type))))
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Bunch_Lines_Type));
+ b = tmp_ptr;
+ }
+ if (NULL == b)
return NULL;
if (Bunch_Lines == NULL)
@@ -1194,7 +1198,10 @@ Line *dup_line(Line *l) /*{{{*/
n = l->len;
#endif
- neew = (Line *) SLmalloc (sizeof(Line));
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Line));
+ neew = tmp_ptr;
+ }
if ((neew == NULL) ||
(NULL == (neew->data = (unsigned char *) SLmalloc (n))))
{
@@ -1586,7 +1593,8 @@ int jed_set_buffer_hook (Buffer *buffer, char *name, SLang_Name_Type *nt)
if (b == NULL)
{
- b = (Jed_Buffer_Hook_Type *)SLmalloc (sizeof (Jed_Buffer_Hook_Type));
+ void *tmp_ptr = SLmalloc (sizeof(Jed_Buffer_Hook_Type));
+ b = tmp_ptr;
if (b == NULL)
return -1;
memset ((char *) b, 0, sizeof (Jed_Buffer_Hook_Type));
diff --git a/src/dfasyntx.c b/src/dfasyntx.c
index b93cb48..b320fb8 100644
--- a/src/dfasyntx.c
+++ b/src/dfasyntx.c
@@ -121,7 +121,10 @@ static Highlight *init_highlight (void)
{
Highlight *result;
- result = (Highlight *) SLmalloc (sizeof (Highlight));
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Highlight));
+ result = tmp_ptr;
+ }
if (result != NULL)
{
memset ((char *) result, 0, sizeof (Highlight));
@@ -156,7 +159,10 @@ static void add_rule (Highlight *h, char *rule, int length,
* accepting.
*/
add_nfa_trans (h, is_begin ? 1 : 0, start, NULL);
- acc = (Accept *) SLmalloc (sizeof(Accept));
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Accept));
+ acc = tmp_ptr;
+ }
if (acc == NULL)
goto error; /* grotty, I know, but... */
acc->next = h->accept;
@@ -444,7 +450,10 @@ static void add_nfa_trans (Highlight *h, int from, int to, Set set)
int i;
unsigned char other[UCHAR_MAX+1], in[UCHAR_MAX+1];
- trans = (NFA *) SLmalloc(sizeof(*trans));
+ {
+ void *tmp_ptr = SLmalloc (sizeof(*trans));
+ trans = tmp_ptr;
+ }
if (trans)
{
trans->next = h->nfa;
@@ -556,7 +565,10 @@ static void make_dfa (Highlight *h)
*/
h->dfa_states = 0;
- h->dfa = tail = (DFA *) SLmalloc(sizeof(DFA));
+ {
+ void *tmp_ptr = SLmalloc (sizeof(DFA));
+ h->dfa = tail = tmp_ptr;
+ }
if (tail == NULL)
goto error;
@@ -577,7 +589,11 @@ static void make_dfa (Highlight *h)
* zero and one, and is the start state for the DFA when we are
* at the beginning of a line.
*/
- if (NULL == (tail->next = (DFA *) SLmalloc(sizeof(DFA))))
+ {
+ void *tmp_ptr = SLmalloc (sizeof(DFA));
+ tail->next = tmp_ptr;
+ }
+ if (NULL == tail->next)
goto error;
tail = tail->next;
memset ((char *) tail, 0, sizeof (DFA));
@@ -631,7 +647,11 @@ static void make_dfa (Highlight *h)
if (!search)
{
- if (NULL == (search = tail->next = (DFA *) SLmalloc(sizeof(DFA))))
+ {
+ void *tmp_ptr = SLmalloc (sizeof(DFA));
+ search = tail->next = tmp_ptr;
+ }
+ if (NULL == search)
goto error;
tail = tail->next;
if (NULL == (tail->nfa_set = (unsigned char *)SLmalloc(setsize)))
@@ -805,7 +825,10 @@ static int load_dfa (Highlight *h, char *name)
get(buffer);
if (!sscanf(buffer, "accept %d", &accepts))
goto error;
- accept = (Accept *) SLmalloc(sizeof(Accept) * accepts);
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Accept) * accepts);
+ accept = tmp_ptr;
+ }
if (!accept)
goto error;
for (i=0; i<accepts; i++)
@@ -828,7 +851,10 @@ static int load_dfa (Highlight *h, char *name)
get(buffer);
if (!sscanf(buffer, "dfa %d", &dfa_states))
goto error;
- dfa = (DFA *) SLmalloc(sizeof(DFA) * dfa_states);
+ {
+ void *tmp_ptr = SLmalloc (sizeof(DFA) * dfa_states);
+ dfa = tmp_ptr;
+ }
if (!dfa)
goto error;
for (i=0; i<dfa_states; i++)
diff --git a/src/hooks.c b/src/hooks.c
index dae7be2..8db70a4 100644
--- a/src/hooks.c
+++ b/src/hooks.c
@@ -316,7 +316,10 @@ static char **build_arg_list (unsigned int n, va_list ap)
char **s;
unsigned int i;
- s = (char **)SLmalloc ((n+1) * sizeof (char *));
+ {
+ void *tmp_ptr = SLmalloc ((n+1) * sizeof (char *));
+ s = tmp_ptr;
+ }
if (s == NULL)
return NULL;
diff --git a/src/ledit.c b/src/ledit.c
index 89d21c9..80f3bc3 100644
--- a/src/ledit.c
+++ b/src/ledit.c
@@ -2086,7 +2086,10 @@ int jed_add_init_slang_hook (int (*hook)(void))
if (hook == NULL)
return 0;
- h = (Init_SLang_Hook_Type *)SLmalloc (sizeof (Init_SLang_Hook_Type));
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Init_SLang_Hook_Type));
+ h = tmp_ptr;
+ }
if (h == NULL)
return -1;
diff --git a/src/menu.c b/src/menu.c
index 06f9ce9..8ef15de 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -294,7 +294,11 @@ static Menu_Popup_Type *create_menu_popup (char *name, unsigned int num_items)
if (num_items == 0)
num_items = 5;
- if (NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *))))
+ {
+ void *tmp_ptr = SLmalloc (num_items * sizeof (Menu_Node_Type *));
+ m->subnodes = tmp_ptr;
+ }
+ if (NULL == m->subnodes)
{
free_menu_node ((Menu_Node_Type *) m);
return NULL;
@@ -316,7 +320,11 @@ static Menu_Bar_Type *create_menu_bar (char *name, unsigned int num_items)
if (num_items == 0)
num_items = 5;
- if ((NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *))))
+ {
+ void *tmp_ptr = SLmalloc (num_items * sizeof (Menu_Node_Type *));
+ m->subnodes = tmp_ptr;
+ }
+ if ((NULL == m->subnodes)
|| (NULL == (m->item_columns = jed_malloc0 (num_items * sizeof (int)))))
{
free_menu_node ((Menu_Node_Type *) m);
@@ -428,7 +436,10 @@ static int check_subnode_space (Menu_Popup_Type *m, unsigned int dn)
num = m->max_subnodes + dn;
- subnodes = (Menu_Node_Type **)SLrealloc ((char *)m->subnodes, num * sizeof (Menu_Node_Type *));
+ {
+ void *tmp_ptr = SLrealloc ((char *)m->subnodes, num * sizeof (Menu_Node_Type *));
+ subnodes = tmp_ptr;
+ }
if (subnodes == NULL)
return -1;
m->subnodes = subnodes;
@@ -439,7 +450,10 @@ static int check_subnode_space (Menu_Popup_Type *m, unsigned int dn)
int *item_columns;
unsigned int i;
- item_columns = (int *)SLrealloc ((char *)b->item_columns, num * sizeof(int));
+ {
+ void *tmp_ptr = SLrealloc ((char *)b->item_columns, num * sizeof(int));
+ item_columns = tmp_ptr;
+ }
if (item_columns == NULL)
return -1;
diff --git a/src/undo.c b/src/undo.c
index 24aa5c1..42c360f 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -326,7 +326,11 @@ void create_undo_ring() /*{{{*/
Undo_Object_Type *uo;
int n;
- if (NULL == (ur = (Undo_Type *) SLmalloc (sizeof(Undo_Type))))
+ {
+ void *tmp_ptr = SLmalloc (sizeof(Undo_Type));
+ ur = tmp_ptr;
+ }
+ if (NULL == ur)
{
msg_error("Unable to malloc space for undo!");
return;
diff --git a/src/vfile.c b/src/vfile.c
index df67221..0745716 100644
--- a/src/vfile.c
+++ b/src/vfile.c
@@ -121,7 +121,11 @@ VFILE *vstream(int fd, unsigned int size, unsigned int mode) /*{{{*/
{
VFILE *v;
- if (NULL == (v = (VFILE *) SLmalloc(sizeof(VFILE)))) return(NULL);
+ {
+ void *tmp_ptr = SLmalloc (sizeof(VFILE));
+ v = tmp_ptr;
+ }
+ if (NULL == v) return(NULL);
v->bmax = v->bp = v->buf = NULL;
v->fd = fd;
v->eof = NULL;
diff --git a/src/vterm.c b/src/vterm.c
index bad1080..17464ad 100644
--- a/src/vterm.c
+++ b/src/vterm.c
@@ -107,7 +107,11 @@ int vterm_init_display (int rows, int cols)
{
SLsmg_Char_Type *s;
- if (NULL == (s = (SLsmg_Char_Type *) SLmalloc (cols * sizeof (SLsmg_Char_Type))))
+ {
+ void *tmp_ptr = SLmalloc (cols * sizeof (SLsmg_Char_Type));
+ s = tmp_ptr;
+ }
+ if (NULL == s)
{
vterm_reset_display ();
return -1;
diff --git a/src/xterm.c b/src/xterm.c
index dc766e1..6853749 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -403,7 +403,8 @@ static SLwchar_Type *bytes_to_wchars (unsigned char *s, unsigned int nchars)
{
unsigned int i;
- SLwchar_Type *w = (SLwchar_Type *)SLmalloc(nchars*sizeof(SLwchar_Type));
+ void *tmp_ptr = SLmalloc(nchars*sizeof(SLwchar_Type));
+ SLwchar_Type *w = tmp_ptr;
if (w == NULL)
return NULL;
@@ -420,7 +421,11 @@ static SLwchar_Type *utf8nt_to_wchars(unsigned char *s, unsigned int len, unsign
unsigned char *smax;
nchars = SLutf8_strlen(s, 0);
- if (NULL == (w = (SLwchar_Type *)SLmalloc(nchars*sizeof(SLwchar_Type))))
+ {
+ void *tmp_ptr = SLmalloc(nchars*sizeof(SLwchar_Type));
+ w = tmp_ptr;
+ }
+ if (NULL == w)
{
*ncharsp = 0;
return NULL;
@@ -1010,7 +1015,11 @@ static void cover_exposed_area (int x, int y, int width, int height, int count)
if (max_col > JX_Screen_Cols) max_col = JX_Screen_Cols;
if (max_row > JX_Screen_Rows) max_row = JX_Screen_Rows;
- if (NULL != (s = (SLsmg_Char_Type *)SLmalloc(width_chars*sizeof(SLsmg_Char_Type))))
+ {
+ void *tmp_ptr = SLmalloc(width_chars*sizeof(SLsmg_Char_Type));
+ s = tmp_ptr;
+ }
+ if (NULL != s)
{
while (row < max_row)
{
--
Debian packaging of JED
More information about the Pkg-jed-commit
mailing list