Merge branch 'bc/doc-interpret-trailers-grammofix' into maint
[gitweb.git] / ewah / ewah_io.c
index 43481b9c60c8afe30d6916650dd0e765065715c9..bed1994551cd03532fe56913b0e27343834c805f 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "git-compat-util.h"
 #include "ewok.h"
@@ -134,11 +133,7 @@ int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
        self->buffer_size = self->alloc_size = get_be32(ptr);
        ptr += sizeof(uint32_t);
 
-       self->buffer = ewah_realloc(self->buffer,
-               self->alloc_size * sizeof(eword_t));
-
-       if (!self->buffer)
-               return -1;
+       REALLOC_ARRAY(self->buffer, self->alloc_size);
 
        /*
         * Copy the raw data for the bitmap as a whole chunk;
@@ -146,8 +141,8 @@ int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
         * the endianness conversion in a separate pass to ensure
         * we're loading 8-byte aligned words.
         */
-       memcpy(self->buffer, ptr, self->buffer_size * sizeof(uint64_t));
-       ptr += self->buffer_size * sizeof(uint64_t);
+       memcpy(self->buffer, ptr, self->buffer_size * sizeof(eword_t));
+       ptr += self->buffer_size * sizeof(eword_t);
 
        for (i = 0; i < self->buffer_size; ++i)
                self->buffer[i] = ntohll(self->buffer[i]);
@@ -180,11 +175,7 @@ int ewah_deserialize(struct ewah_bitmap *self, int fd)
                return -1;
 
        self->buffer_size = self->alloc_size = (size_t)ntohl(word_count);
-       self->buffer = ewah_realloc(self->buffer,
-               self->alloc_size * sizeof(eword_t));
-
-       if (!self->buffer)
-               return -1;
+       REALLOC_ARRAY(self->buffer, self->alloc_size);
 
        /** 64 bit x N -- compressed words */
        buffer = self->buffer;