r128: Another registry update. Changes:
[bbaumbach/samba-autobuild/.git] / source4 / lib / talloctort.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Samba temporary memory allocation functions -- torturer
4    Copyright (C) 2001 by Martin Pool <mbp@samba.org>
5    
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 2 of the License, or
9    (at your option) any later version.
10    
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.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #error SAMBA4 clean up
22 #error this file should be (re)moved 
23 #error and all unused stuff should go
24
25 #include "includes.h"
26
27 #define NCTX 10
28 #define NOBJ 20
29
30 int main(void)
31 {
32         int i;
33         TALLOC_CTX *ctx[NCTX];
34
35         for (i = 0; i < NCTX; i++) {
36                 ctx[i] = talloc_init("torture(%d)", i);
37         }
38
39         for (i = 0; i < NCTX; i++) {
40                 int j;
41                 for (j = 0; j < NOBJ; j++) {
42                         char *p;
43                         size_t size = 1<<(i/3+j);
44
45                         p = talloc(ctx[i], size);
46                         if (!p) {
47                                 fprintf(stderr,
48                                         "failed to talloc %.0f bytes\n",
49                                         (double) size);
50                                 exit(1);
51                         }
52
53                         memset(p, 'A' + j, size);
54                 }
55         }
56
57         for (i = 0; i < NCTX; i++) {
58                 printf("talloc@%p %-40s %dkB\n", ctx[i],
59                        talloc_pool_name(ctx[i]),
60                        talloc_pool_size(ctx[i]) >> 10);
61         }
62
63         printf("%s", talloc_describe_all(ctx[0]));
64
65         for (i = NCTX - 1; i >= 0; i--)
66                 talloc_destroy(ctx[i]);
67
68         return 0;
69 }