"Fixing my FORTRAN". Ensure we always have some valid char converter for the
[tprouty/samba.git] / source / lib / bitmap.c
index 26d21d085f685111ed804cc6c3deb6852f4b8139..3fa20cdd112c8429f39b253f6e953ec821001f8c 100644 (file)
@@ -83,6 +83,20 @@ struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n)
        return bm;
 }
 
+/****************************************************************************
+copy as much of the source bitmap as will fit in the destination bitmap.
+****************************************************************************/
+
+int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src)
+{
+        int count = MIN(dst->n, src->n);
+
+        SMB_ASSERT(dst->b != src->b);
+       memcpy(dst->b, src->b, sizeof(dst->b[0])*(count+31)/32);
+
+        return count;
+}
+
 /****************************************************************************
 set a bit in a bitmap
 ****************************************************************************/
@@ -129,7 +143,7 @@ wraparound
 ****************************************************************************/
 int bitmap_find(struct bitmap *bm, unsigned ofs)
 {
-       int i, j;
+       unsigned int i, j;
 
        if (ofs > bm->n) ofs = 0;