Additional malloc failure checks.

This commit is contained in:
orion 2003-04-20 17:08:56 +00:00
parent 81d6b31102
commit 26bf26a836
3 changed files with 15 additions and 4 deletions

View File

@ -113,6 +113,7 @@ sndbuf_free(struct snd_dbuf *b)
int
sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
{
u_int8_t *tmpbuf;
if (b->maxsize == 0)
return 0;
if (blkcnt == 0)
@ -126,9 +127,12 @@ sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
b->blkcnt = blkcnt;
b->blksz = blksz;
b->bufsize = blkcnt * blksz;
if (b->tmpbuf)
free(b->tmpbuf, M_DEVBUF);
b->tmpbuf = malloc(b->bufsize, M_DEVBUF, M_NOWAIT);
tmpbuf = malloc(b->bufsize, M_DEVBUF, M_NOWAIT);
if (tmpbuf == NULL)
return ENOMEM;
free(b->tmpbuf, M_DEVBUF);
b->tmpbuf = tmpbuf;
sndbuf_reset(b);
return 0;
}
@ -144,7 +148,6 @@ sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
bufsize = blksz * blkcnt;
buf = malloc(bufsize, M_DEVBUF, M_NOWAIT);
if (buf == NULL)
return ENOMEM;

View File

@ -210,6 +210,8 @@ static int
feed_16to8_init(struct pcm_feeder *f)
{
f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO);
if (f->data == NULL)
return ENOMEM;
return 0;
}
@ -319,6 +321,8 @@ static int
feed_stereotomono8_init(struct pcm_feeder *f)
{
f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO);
if (f->data == NULL)
return ENOMEM;
return 0;
}
@ -364,6 +368,8 @@ static int
feed_stereotomono16_init(struct pcm_feeder *f)
{
f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO);
if (f->data == NULL)
return ENOMEM;
return 0;
}

View File

@ -250,6 +250,8 @@ feed_rate_init(struct pcm_feeder *f)
struct feed_rate_info *info;
info = malloc(sizeof(*info), M_RATEFEEDER, M_NOWAIT | M_ZERO);
if (info == NULL)
return ENOMEM;
info->src = DSP_DEFAULT_SPEED;
info->dst = DSP_DEFAULT_SPEED;
info->channels = 2;