2006-09-15 11:11:16 +00:00
|
|
|
#include "zxconfig.h"
|
2008-08-14 21:49:26 +00:00
|
|
|
#include "helpers.h"
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
int my_getc(int fd){
|
|
|
|
unsigned char c;
|
|
|
|
if ( rb->read(fd, &c, 1) )
|
|
|
|
return c;
|
|
|
|
else
|
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
off_t my_ftell(int fd){
|
|
|
|
return rb->lseek(fd, 0, SEEK_CUR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int my_putc(char c , int fd){
|
|
|
|
return rb->write(fd,&c,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *my_malloc(size_t size)
|
|
|
|
{
|
|
|
|
static char *offset = NULL;
|
2007-04-21 18:38:25 +00:00
|
|
|
static ssize_t totalSize = 0;
|
2006-09-15 11:11:16 +00:00
|
|
|
char *ret;
|
|
|
|
|
|
|
|
int remainder = size % 4;
|
|
|
|
|
|
|
|
size = size + 4-remainder;
|
|
|
|
|
|
|
|
if (offset == NULL)
|
|
|
|
{
|
2007-04-21 19:07:15 +00:00
|
|
|
offset = rb->plugin_get_audio_buffer((size_t *)&totalSize);
|
2006-09-15 11:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (size + 4 > abs(totalSize) )
|
|
|
|
{
|
|
|
|
/* We've made our point. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = offset + 4;
|
|
|
|
*((unsigned int *)offset) = size;
|
|
|
|
|
|
|
|
offset += size + 4;
|
|
|
|
totalSize -= size + 4;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|