|
|
1.1 root 1: /* mkpool.c - mkpool */
2:
3: #include <conf.h>
4: #include <kernel.h>
5: #include <mark.h>
6: #include <bufpool.h>
7:
8: /*------------------------------------------------------------------------
9: * mkpool -- allocate memory for a buffer pool and link together
10: *------------------------------------------------------------------------
11: */
1.1.1.2 ! root 12: mkpool(bufsiz, numbufs)
1.1 root 13: int bufsiz, numbufs;
14: {
15: int poolid;
16: char *where;
17:
1.1.1.2 ! root 18: #ifdef DEBUG
! 19: dotrace("mkpool", &bufsiz, 2);
! 20: #endif
1.1 root 21: #ifdef MEMMARK
22: if ( unmarked(bpmark) )
23: poolinit();
24: #endif
1.1.1.2 ! root 25: disable();
1.1 root 26: if (bufsiz<BPMINB || bufsiz>BPMAXB
27: || numbufs<1 || numbufs>BPMAXN
28: || nbpools >= NBPOOLS
1.1.1.2 ! root 29: || (where=getmem((bufsiz+sizeof(int))*numbufs)) == SYSERR) {
! 30: restore();
1.1 root 31: return(SYSERR);
32: }
33: poolid = nbpools++;
34: bptab[poolid].bpnext = where;
35: bptab[poolid].bpsize = bufsiz;
36: bptab[poolid].bpsem = screate(numbufs);
37: bufsiz+=sizeof(int);
38: for (numbufs-- ; numbufs>0 ; numbufs--,where+=bufsiz)
39: *( (int *) where ) = (int)(where+bufsiz);
40: *( (int *) where) = (int) NULL;
1.1.1.2 ! root 41: restore();
1.1 root 42: return(poolid);
43: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.