** **
\*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
#include "main.h"
/*
read(fh, buffer, 8);
chunk=(buffer[4]) + (buffer[5]<<8) + (buffer[6]<<16) + (buffer[7]<<24);
size -= (8+chunk);
-// printf("%c%c%c%c lenght=%d\n",buffer[0],buffer[1],buffer[2],buffer[3],chunk);
+// printf("%c%c%c%c length=%d\n",buffer[0],buffer[1],buffer[2],buffer[3],chunk);
if (size < 0)
{
close(fh);
}
if (!strncmp((char *)buffer, "fmt ", 4))
{
- if (chunk != 16)
+ if (chunk < 16)
{
close(fh);
errno = 0;
*length = ((signed long)chunk)>>1;
if (left)
*left = ((signed long)chunk)>>1;
+// printf("left=%d\n",*left);
} else
if (bytes==2 && channels==2)
{
break;
default:
- PERROR("codec %d is not supported, exitting...\n", codec);
- exit(-1);
+ FATAL("codec %d is not supported.\n", codec);
}
if (l>0 && left)
{
temp = tonesettone_temp;
tonesettone_temp = tonesettone_temp->next;
- free(temp);
+ FREE(temp, sizeof(struct tonesettone));
memuse--;
}
temp = toneset_temp;
toneset_temp = toneset_temp->next;
- free(temp);
+ FREE(temp, sizeof(struct toneset));
memuse--;
}
toneset_first = NULL;
printf("PBX: Fetching tones '%s'\n", p);
PDEBUG(DEBUG_PORT, "fetching tones directory '%s'\n", p);
- *toneset_nextpointer = (struct toneset *)calloc(1, sizeof(struct toneset));
- if (*toneset_nextpointer == NULL)
- {
- PERROR("No memory for tone set: '%s'\n",p);
- return(0);
- }
+ *toneset_nextpointer = (struct toneset *)MALLOC(sizeof(struct toneset));
memuse++;
memory += sizeof(struct toneset);
- memset(*toneset_nextpointer, 0 , sizeof(struct toneset));
SCPY((*toneset_nextpointer)->directory, p);
tonesettone_nextpointer = &(*toneset_nextpointer)->first;
continue;
}
- /* allocate tone */
- *tonesettone_nextpointer = (struct tonesettone *)calloc(1, sizeof(struct tonesettone)+tone_size);
- if (*toneset_nextpointer == NULL)
- {
- PERROR("No memory for tone set: '%s'\n",p);
- close(fh);
- fduse--;
- return(0);
- }
+ /* Allocate tone */
+ *tonesettone_nextpointer = (struct tonesettone *)MALLOC(sizeof(struct tonesettone)+tone_size);
memuse++;
//printf("tone:%s, %ld bytes\n", name, tone_size);
- memset(*tonesettone_nextpointer, 0 , sizeof(struct tonesettone)+tone_size);
memory += sizeof(struct tonesettone)+tone_size;
samples ++;