~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to testsuite/fptr_array.c

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include "fptr_array.h"
 
3
 
 
4
static int testfunc1()
 
5
{
 
6
    return 3;
 
7
}
 
8
 
 
9
static char *testfunc2(int *p)
 
10
{
 
11
    char *c = (char*) malloc(sizeof(char));
 
12
    *c = (char) (0xff & *p);
 
13
    return c;
 
14
}
 
15
 
 
16
void fptr_array_set(struct foo *s)
 
17
{
 
18
    s->fptr_array[1] = testfunc1;
 
19
    s->c[3] = testfunc2;
 
20
}
 
21
 
 
22
int *fptr_array_test(struct foo *s, int *p)
 
23
{
 
24
    int *results = (int*) malloc(sizeof(int) * 2);
 
25
    results[0] = (s->fptr_array[1])();
 
26
    results[1] = (int) (*(s->c[3])(p));
 
27
    return results;
 
28
}
 
29