/*
* badblocks.c --- routines to manipulate the bad block structure
- *
+ *
* Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
{
ext2_u32_list bb;
errcode_t retval;
-
+
retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb);
if (retval)
return retval;
bb->magic = EXT2_ET_MAGIC_BADBLOCKS_LIST;
bb->size = size ? size : 10;
bb->num = num;
- retval = ext2fs_get_mem(bb->size * sizeof(blk_t), &bb->list);
- if (!bb->list) {
+ retval = ext2fs_get_array(bb->size, sizeof(blk_t), &bb->list);
+ if (retval) {
ext2fs_free_mem(&bb);
return retval;
}
*ret = bb;
return 0;
}
-
+
/*
* This procedure creates an empty u32 list.
errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest)
{
errcode_t retval;
-
+
retval = make_u32_list(src->size, src->num, src->list, dest);
if (retval)
return retval;
return high;
while (low < high) {
- mid = (low+high)/2;
+ mid = ((unsigned)low + (unsigned)high)/2;
if (mid == low || mid == high)
break;
if (blk == bb->list[mid])
if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
return 0;
-
+
if (iter->ptr < bb->num) {
*blk = bb->list[iter->ptr++];
return 1;
- }
+ }
*blk = 0;
return 0;
}