[Pkg-jed-commit] [SCM] Debian packaging of JED branch, jo-upstream-fixes, updated. 222c5d0c856c5cf1eb218493eddbf33d6e43fd5c

Jörg Sommer joerg at alea.gnuu.de
Sun Aug 24 17:07:40 UTC 2008


The following commit has been merged in the jo-upstream-fixes branch:
commit 8e7aaf0299e0d1a3063454b568b9c918548d6474
Author: Jörg Sommer <joerg at alea.gnuu.de>
Date:   Sun Aug 24 17:41:40 2008 +0200

    Make return type of jed_malloc0() void*
    
    The cast from char* to any other pointer type might increases required
    alignment of target type. On some architectures (like alpha) this
    triggers an error message at runtime, if the access of a pointer is
    unaligned:
    
    % cat cast-test.c
    int main(void)
    {
        char buf[10] = { 0 };
        int *a = (int*)&buf[1];
        *a = 0x7a7a7a;
    
        return 0;
    }
    % gcc -Wall -Wcast-align cast-test.c -o cast-test
    cast-test.c: In function `main':
    cast-test.c:4: warning: cast increases required alignment of target type
    % ./cast-test
    Unaligned access pid=398552 <cast-test> va=0x11fffbfe1 pc=0x12000112c ra=0x1200010ac inst=0xb0220000

diff --git a/src/abbrev.c b/src/abbrev.c
index eeb9144..b8400a2 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -161,7 +161,7 @@ void create_abbrev_table (char *name, char *word_chars) /*{{{*/
    tbl = find_table (name, 0);
    if (tbl == NULL)
      {
-	tbl = (Abbrev_Table_Type *) jed_malloc0 (sizeof (Abbrev_Table_Type));
+	tbl = jed_malloc0 (sizeof (Abbrev_Table_Type));
 	if (tbl == NULL)
 	  return;
 	if (NULL == (tbl->name = SLang_create_slstring (name)))
diff --git a/src/blocal.c b/src/blocal.c
index 8d2763d..621d98f 100644
--- a/src/blocal.c
+++ b/src/blocal.c
@@ -72,7 +72,7 @@ void jed_make_blocal_var (char *name) /*{{{*/
    if ((table == NULL)
        || (table->num == MAX_BLOCAL_VARS_PER_TABLE))
      {
-	table = (Jed_BLocal_Table_Type *) jed_malloc0 (sizeof (Jed_BLocal_Table_Type));
+	table = jed_malloc0 (sizeof (Jed_BLocal_Table_Type));
 	if (table == NULL) 
 	  return;
 
diff --git a/src/buffer.c b/src/buffer.c
index 9c5545b..7fd9438 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1014,7 +1014,7 @@ Buffer *make_buffer (char *name, char *dir, char *file) /*{{{*/
 {
    Buffer *newB;
    
-   newB = (Buffer *) jed_malloc0 (sizeof(Buffer));
+   newB = jed_malloc0 (sizeof(Buffer));
    
    if (newB == NULL)
      exit_error("Out of memory", 0);
diff --git a/src/hooks.c b/src/hooks.c
index 40ca1e1..dae7be2 100644
--- a/src/hooks.c
+++ b/src/hooks.c
@@ -102,7 +102,7 @@ static Hook_List_Type *new_hook_list (char *name)
 {
    Hook_List_Type *h;
 
-   h = (Hook_List_Type *) jed_malloc0 (sizeof (Hook_List_Type));
+   h = jed_malloc0 (sizeof (Hook_List_Type));
    if (h == NULL)
      return NULL;
 
@@ -154,7 +154,7 @@ static int insert_hook_1 (char *hook, SLang_Name_Type *nt, int append)
 	return 0;
      }
 
-   if (NULL == (h = (Hook_Type *) jed_malloc0 (sizeof (Hook_Type))))
+   if (NULL == (h = jed_malloc0 (sizeof (Hook_Type))))
      return -1;
 	
    h->nt = nt;
diff --git a/src/indent.c b/src/indent.c
index 01961ab..147208b 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1416,7 +1416,7 @@ static Syntax_Table_Type *allocate_syntax_table (char *name)
 {
    Syntax_Table_Type *table;
 
-   if (NULL == (table = (Syntax_Table_Type *) jed_malloc0 (sizeof (Syntax_Table_Type))))
+   if (NULL == (table = jed_malloc0 (sizeof (Syntax_Table_Type))))
      return NULL;
 
    if (NULL == (name = SLang_create_slstring (name)))
diff --git a/src/menu.c b/src/menu.c
index 1f0bd9e..8f3d23e 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -267,7 +267,7 @@ static Menu_Node_Type *create_menu_node (char *name, int node_type,
 {
    Menu_Node_Type *m;
 
-   m = (Menu_Node_Type *) jed_malloc0 (sizeof_node);
+   m = jed_malloc0 (sizeof_node);
    if (m == NULL)
      return NULL;
 
@@ -317,7 +317,7 @@ static Menu_Bar_Type *create_menu_bar (char *name, unsigned int num_items)
      num_items = 5;
 
    if ((NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *))))
-       || (NULL == (m->item_columns = (int *)jed_malloc0 (num_items * sizeof (int)))))
+       || (NULL == (m->item_columns = jed_malloc0 (num_items * sizeof (int)))))
      {
 	free_menu_node ((Menu_Node_Type *) m);
 	return NULL;
diff --git a/src/misc.c b/src/misc.c
index 910eedf..4755fad 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -699,11 +699,11 @@ int jed_case_strcmp (char *a, char *b)
      }
 }
 
-char *jed_malloc0 (unsigned int len)
+void *jed_malloc0 (unsigned int len)
 {
-   char *s = SLmalloc (len);
+   void *s = SLmalloc (len);
    if (s != NULL)
-     memset ((char *) s, 0, len);
+     memset (s, 0, len);
    return s;
 }
 
diff --git a/src/misc.h b/src/misc.h
index aae1e95..20f71a9 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -20,7 +20,7 @@ extern int jed_check_string_key_buffer (void);
 extern int jed_getkey_wchar (SLwchar_Type *);
 extern void jed_ungetkey_wchar (SLwchar_Type);
 
-extern char *jed_malloc0 (unsigned int);
+extern void *jed_malloc0 (unsigned int);
 
 extern int begin_keyboard_macro(void);
 extern int macro_query(void);
diff --git a/src/paste.c b/src/paste.c
index 44db0a0..6b0b814 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -133,7 +133,7 @@ static Mark *create_mark (unsigned int flags) /*{{{*/
 {
    Mark *m;
    
-   if (NULL == (m = (Mark *) jed_malloc0 (sizeof(Mark))))
+   if (NULL == (m = jed_malloc0 (sizeof(Mark))))
      exit_error("create-mark: malloc error", 0);
    
    jed_init_mark (m, flags);
@@ -186,7 +186,7 @@ static Mark *allocate_mark (Jed_Mark_Array_Type **ap, Mark **mp, unsigned int fl
    if ((a == NULL)
        || (a->num_marks == JED_MAX_MARK_ARRAY_SIZE))
      {
-	if (NULL == (b = (Jed_Mark_Array_Type *) jed_malloc0 (sizeof(Jed_Mark_Array_Type))))
+	if (NULL == (b = jed_malloc0 (sizeof(Jed_Mark_Array_Type))))
 	  {
 	     exit_error("allocate_mark: malloc error", 0);
 	  }
@@ -610,7 +610,7 @@ int narrow_to_lines () /*{{{*/
    Line *beg;
    Narrow_Type *nt;
    
-   if (NULL == (nt = (Narrow_Type *) jed_malloc0 (sizeof(Narrow_Type))))
+   if (NULL == (nt = jed_malloc0 (sizeof(Narrow_Type))))
      return 0;
    
    if (!check_region(&Number_One)) return(0);       /* spot pushed */
@@ -1266,7 +1266,7 @@ SLang_MMT_Type *jed_make_user_object_mark (void) /*{{{*/
    SLang_MMT_Type *mmt;
    Mark *m;
    
-   if (NULL == (um = (User_Mark_Type *) jed_malloc0 (sizeof(User_Mark_Type))))
+   if (NULL == (um = jed_malloc0 (sizeof(User_Mark_Type))))
      return NULL;
      
    if (NULL == (mmt = SLang_create_mmt (JED_MARK_TYPE, (VOID_STAR) um)))
@@ -1587,7 +1587,7 @@ void jed_push_narrow (void) /*{{{*/
 {
    Jed_Save_Narrow_Type *save_narrow;
    
-   if (NULL == (save_narrow = (Jed_Save_Narrow_Type *) jed_malloc0 (sizeof (Jed_Save_Narrow_Type))))
+   if (NULL == (save_narrow = jed_malloc0 (sizeof (Jed_Save_Narrow_Type))))
      {
 	exit_error ("push_narrow: malloc error.", 0);
      }
diff --git a/src/screen.c b/src/screen.c
index a6c7fa6..d2242cd 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1899,7 +1899,7 @@ static void alloc_display (void)
    jed_get_screen_size (&r, &c);
    jed_update_window_sizes (r, c);
 
-   if (NULL == (JScreen = (Screen_Type *) jed_malloc0 (sizeof (Screen_Type) * r)))
+   if (NULL == (JScreen = jed_malloc0 (sizeof (Screen_Type) * r)))
      exit_error ("Out of memory", 0);
 
    for (i = 0; i < r; i++)
diff --git a/src/vterm.c b/src/vterm.c
index ef5f029..bad1080 100644
--- a/src/vterm.c
+++ b/src/vterm.c
@@ -99,7 +99,7 @@ int vterm_init_display (int rows, int cols)
    VTerm_Num_Cols = cols;
    VTerm_Num_Rows = rows;
 
-   VTerm_Display = (SLsmg_Char_Type **)jed_malloc0 (rows * sizeof (SLsmg_Char_Type *));
+   VTerm_Display = jed_malloc0 (rows * sizeof (SLsmg_Char_Type *));
    if (VTerm_Display == NULL)
      return -1;
 
diff --git a/src/window.c b/src/window.c
index aeec60b..a92007e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -32,7 +32,7 @@ Window_Type *create_window(int sy, int sx, int rows, int col, int width) /*{{{*/
 {
     Window_Type *w;
 
-    if (NULL == (w = (Window_Type *) jed_malloc0 (sizeof(Window_Type))))
+    if (NULL == (w = jed_malloc0 (sizeof(Window_Type))))
       {
 	  exit_error("create_window: malloc error.", 0);
       }

-- 
Debian packaging of JED



More information about the Pkg-jed-commit mailing list