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
49
50
51
|
/* nd.c
*/
#include <xos.h>
#include <fitsy.h>
void *ft_alloc2d(size, xstar, ystar, xsize, ysize)
int size;
int xstar;
int ystar;
int xsize;
int ysize;
{
void *ptr;
Malloc(ptr, xsize * ysize * size);
return ft_make2d(ptr, size, xstar, ystar, xsize, ysize);
}
char **ft_make2d(ptr, size, xstar, ystar, xsize, ysize)
char *ptr;
int size;
int xstar;
int ystar;
int xsize;
int ysize;
{
char **ptr2d;
if ( ptr == NULL ) return NULL;
Malloc(ptr2d, ysize * sizeof(void *));
if ( ptr2d == NULL ) return NULL;
for (; ysize--;) {
ptr2d[ysize] = ptr + xsize * ysize * size - xstar * size;
}
return ptr2d - ystar;
}
void ft_free2d(ptr2d, size, xstar, ystar)
char **ptr2d;
int size;
int xstar;
int ystar;
{
free(&ptr2d[ystar][xstar * size]);
free(&ptr2d[ystar]);
}
|