📄 bitmap_test.c
字号:
/* $Id: bitmap_test.c,v 1.2 2000/04/06 07:26:53 jm Exp $ * Dynamic bitmap test * * Dynamic hierarchial IP tunnel * Copyright (C) 1998-2000, Dynamics group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. See README and COPYING for * more details. */#include <stdio.h>#include <assert.h>#include "bitmap.h"extern int opt_debug;#if 0struct bitmap { int size; /* number of bits in the bitmap */ int u32s; /* number of 32-bit values needed for the bitmap */ __u32 *bits; /* dynamically allocated storage for bits */};struct bitmap *bitmap_init(int start_size);void bitmap_destroy(struct bitmap *map);int bitmap_get_free(struct bitmap *map);int bitmap_release(struct bitmap *map, int bit);voit bitmap_debug_print(struct bitmap *map);#endifint main(int argc, char *argv[]){ struct bitmap *map; int i, j; printf("Bitmap test\n\n"); map = bitmap_init(10); assert(map != NULL); bitmap_debug_print(map); for (i = 0; i < 33; i++) { j = bitmap_get_free(map); printf("%i ==> %i\n", i, j); bitmap_debug_print(map); printf("\n"); } printf("Releasing..\n"); for (i = 0; i < 33; i++) { bitmap_release(map, i); printf("release %i:\n", i); bitmap_debug_print(map); printf("\n"); } bitmap_destroy(map); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -