4 Copyright (C) Amitay Isaacs 2015
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #include "common/reqid.c"
29 struct reqid_context *reqid_ctx;
30 TALLOC_CTX *mem_ctx = talloc_new(NULL);
35 ret = reqid_init(mem_ctx, INT_MAX-200, &reqid_ctx);
38 data = talloc_zero(mem_ctx, int);
41 for (i=0; i<1024*1024; i++) {
42 reqid = reqid_new(reqid_ctx, data);
46 for (i=0; i<1024; i++) {
47 tmp = reqid_find(reqid_ctx, i, int);
51 for (i=0; i<1024; i++) {
52 ret = reqid_remove(reqid_ctx, i);
56 for (i=0; i<1024; i++) {
57 tmp = reqid_find(reqid_ctx, i, int);
61 for (i=0; i<1024; i++) {
62 ret = reqid_remove(reqid_ctx, i);
63 assert(ret == ENOENT);
66 talloc_free(reqid_ctx);
67 assert(talloc_get_size(mem_ctx) == 0);
69 ret = reqid_init(mem_ctx, INT_MAX-1, &reqid_ctx);
72 reqid = reqid_new(reqid_ctx, data);
73 assert(reqid == INT_MAX);
75 reqid = reqid_new(reqid_ctx, data);
78 reqid_remove(reqid_ctx, 0);
80 reqid = reqid_new(reqid_ctx, data);
83 talloc_free(reqid_ctx);