Don't use struct buf for random small temporary buffers.

This commit is contained in:
Poul-Henning Kamp 2000-05-05 09:05:39 +00:00
parent 8172e29086
commit e4961fbf07
2 changed files with 14 additions and 10 deletions

View file

@ -10,10 +10,10 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/conf.h>
#include <sys/ctype.h>
#include <sys/malloc.h>
#include <i386/isa/isa.h>
#include <i386/isa/timerreg.h>
#include <machine/clock.h>
@ -42,6 +42,8 @@ static struct cdevsw spkr_cdevsw = {
/* bmaj */ -1
};
MALLOC_DEFINE(M_SPKR, "spkr", "Speaker buffer");
/**************** MACHINE DEPENDENT PART STARTS HERE *************************
*
* This section defines a function tone() which causes a tone of given
@ -453,7 +455,7 @@ playstring(cp, slen)
*/
static int spkr_active = FALSE; /* exclusion flag */
static struct buf *spkr_inbuf; /* incoming buf */
static char *spkr_inbuf; /* incoming buf */
int
spkropen(dev, flags, fmt, p)
@ -476,7 +478,7 @@ spkropen(dev, flags, fmt, p)
(void) printf("spkropen: about to perform play initialization\n");
#endif /* DEBUG */
playinit();
spkr_inbuf = geteblk(DEV_BSIZE);
spkr_inbuf = malloc(DEV_BSIZE, M_SPKR, M_WAITOK);
spkr_active = TRUE;
return(0);
}
@ -504,7 +506,7 @@ spkrwrite(dev, uio, ioflag)
int error;
n = uio->uio_resid;
cp = spkr_inbuf->b_data;
cp = spkr_inbuf;
error = uiomove(cp, n, uio);
if (!error) {
cp[n] = '\0';
@ -531,7 +533,7 @@ spkrclose(dev, flags, fmt, p)
{
wakeup((caddr_t)&endtone);
wakeup((caddr_t)&endrest);
brelse(spkr_inbuf);
free(spkr_inbuf, M_SPKR);
spkr_active = FALSE;
return(0);
}

View file

@ -10,10 +10,10 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/conf.h>
#include <sys/ctype.h>
#include <sys/malloc.h>
#include <i386/isa/isa.h>
#include <i386/isa/timerreg.h>
#include <machine/clock.h>
@ -42,6 +42,8 @@ static struct cdevsw spkr_cdevsw = {
/* bmaj */ -1
};
MALLOC_DEFINE(M_SPKR, "spkr", "Speaker buffer");
/**************** MACHINE DEPENDENT PART STARTS HERE *************************
*
* This section defines a function tone() which causes a tone of given
@ -453,7 +455,7 @@ playstring(cp, slen)
*/
static int spkr_active = FALSE; /* exclusion flag */
static struct buf *spkr_inbuf; /* incoming buf */
static char *spkr_inbuf; /* incoming buf */
int
spkropen(dev, flags, fmt, p)
@ -476,7 +478,7 @@ spkropen(dev, flags, fmt, p)
(void) printf("spkropen: about to perform play initialization\n");
#endif /* DEBUG */
playinit();
spkr_inbuf = geteblk(DEV_BSIZE);
spkr_inbuf = malloc(DEV_BSIZE, M_SPKR, M_WAITOK);
spkr_active = TRUE;
return(0);
}
@ -504,7 +506,7 @@ spkrwrite(dev, uio, ioflag)
int error;
n = uio->uio_resid;
cp = spkr_inbuf->b_data;
cp = spkr_inbuf;
error = uiomove(cp, n, uio);
if (!error) {
cp[n] = '\0';
@ -531,7 +533,7 @@ spkrclose(dev, flags, fmt, p)
{
wakeup((caddr_t)&endtone);
wakeup((caddr_t)&endrest);
brelse(spkr_inbuf);
free(spkr_inbuf, M_SPKR);
spkr_active = FALSE;
return(0);
}