blob: db57ea8e02f9bf0b1165e60e4444625369fe7ab7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include "zxconfig.h"
#include "helpers.h"
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;
static size_t totalSize = 0;
char *ret;
int remainder = size % 4;
size = size + 4-remainder;
if (offset == NULL)
{
offset = rb->plugin_get_audio_buffer(&totalSize);
}
if (size + 4 > totalSize)
{
/* We've made our point. */
return NULL;
}
ret = offset + 4;
*((unsigned int *)offset) = size;
offset += size + 4;
totalSize -= size + 4;
return ret;
}
|