File: fptr_array.c

package info (click to toggle)
gauche-c-wrapper 0.6.1-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,440 kB
  • sloc: ansic: 17,899; sh: 14,025; asm: 6,456; lisp: 5,485; yacc: 2,109; makefile: 520; exp: 194; cpp: 157; objc: 144; perl: 2
file content (29 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (8)
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
#include <stdlib.h>
#include "fptr_array.h"

static int testfunc1()
{
    return 3;
}

static char *testfunc2(int *p)
{
    char *c = (char*) malloc(sizeof(char));
    *c = (char) (0xff & *p);
    return c;
}

void fptr_array_set(struct foo *s)
{
    s->fptr_array[1] = testfunc1;
    s->c[3] = testfunc2;
}

int *fptr_array_test(struct foo *s, int *p)
{
    int *results = (int*) malloc(sizeof(int) * 2);
    results[0] = (s->fptr_array[1])();
    results[1] = (int) (*(s->c[3])(p));
    return results;
}