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/>.
25 #include "common/reqid.c"
30 struct reqid_context
*reqid_ctx
;
31 TALLOC_CTX
*mem_ctx
= talloc_new(NULL
);
36 ret
= reqid_init(mem_ctx
, INT_MAX
-200, &reqid_ctx
);
39 data
= talloc_zero(mem_ctx
, int);
42 for (i
=0; i
<1024*1024; i
++) {
43 reqid
= reqid_new(reqid_ctx
, data
);
44 assert(reqid
!= REQID_INVALID
);
47 for (i
=0; i
<1024; i
++) {
48 tmp
= reqid_find(reqid_ctx
, i
, int);
52 for (i
=0; i
<1024; i
++) {
53 ret
= reqid_remove(reqid_ctx
, i
);
57 for (i
=0; i
<1024; i
++) {
58 tmp
= reqid_find(reqid_ctx
, i
, int);
62 for (i
=0; i
<1024; i
++) {
63 ret
= reqid_remove(reqid_ctx
, i
);
64 assert(ret
== ENOENT
);
67 talloc_free(reqid_ctx
);
68 assert(talloc_get_size(mem_ctx
) == 0);
70 ret
= reqid_init(mem_ctx
, INT_MAX
-1, &reqid_ctx
);
73 reqid
= reqid_new(reqid_ctx
, data
);
74 assert(reqid
== INT_MAX
);
76 reqid
= reqid_new(reqid_ctx
, data
);
79 reqid_remove(reqid_ctx
, 0);
81 reqid
= reqid_new(reqid_ctx
, data
);
84 talloc_free(reqid_ctx
);