[pisa-src] r2288 - trunk/libpisa/debug.c

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 15:42:19 +0200

Author: biurrun
Date: Thu Apr 15 15:42:19 2010
New Revision: 2288

Log:
Do not needlessly cast calloc return values.
calloc() returns void*, which is compatible with any pointer.

Modified:
   trunk/libpisa/debug.c

Modified: trunk/libpisa/debug.c
==============================================================================
--- trunk/libpisa/debug.c       Thu Apr 15 15:15:38 2010        (r2287)
+++ trunk/libpisa/debug.c       Thu Apr 15 15:42:19 2010        (r2288)
@@ -333,7 +333,7 @@
     hexdump_max_size = len * 2 + 1;
     hexdump_count    = hexdump_max_size;
 
-    hexdump          = (char *) calloc(hexdump_max_size, sizeof(char));
+    hexdump          = calloc(hexdump_max_size, sizeof(char));
     if (!hexdump) {
         PISA_EXIT("hexdump memory allocation failed\n");
     }
@@ -402,8 +402,8 @@
     hexdump_count      = hexdump_total_size;
     pad_length         = (hexdump_total_size - bytes_per_line) - 
pad_start_position;
 
-    hexdump            = (char *) calloc(hexdump_total_size, sizeof(char));
-    asciidump          = (char *) calloc((bytes_per_line + 2), sizeof(char));
+    hexdump            = calloc(hexdump_total_size, sizeof(char));
+    asciidump          = calloc((bytes_per_line + 2), sizeof(char));
 
     if (!hexdump || !asciidump) {
         PISA_EXIT("memory allocation failed\n");
@@ -447,7 +447,7 @@
                 // Add padding
                 if ((char_index + 1) == len && pad_length > 0
                     && ((hexdump_index + line_index + pad_length) < 
hexdump_total_size)) {
-                    char *padding = (char *) calloc(pad_length + 1, 
sizeof(char));
+                    char *padding = calloc(pad_length + 1, sizeof(char));
                     memset(padding, ' ', pad_length);
                     memset(padding + pad_length, '\0', 1);
                     hexdump_written = snprintf((char *) (hexdump + 
hexdump_index),

Other related posts:

  • » [pisa-src] r2288 - trunk/libpisa/debug.c - Diego Biurrun