File: meta.c

package info (click to toggle)
libffi-platypus-perl 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,860 kB
  • sloc: perl: 7,388; ansic: 6,862; cpp: 53; sh: 19; makefile: 14
file content (35 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (4)
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
#include "libtest.h"

struct mymeta_t {
  int foo;
  char *bar;
};

EXTERN struct mymeta_t*
mymeta_new(int foo, const char *bar)
{
  struct mymeta_t *self;
  self = malloc(sizeof(struct mymeta_t));
  self->foo = foo;
  self->bar = malloc(strlen(bar)+1);
  strcpy(self->bar, bar);
  return self;
}

EXTERN void
mymeta_delete(struct mymeta_t *self)
{
  free(self->bar);
  free(self);
}

EXTERN const char *
mymeta_test(struct mymeta_t *self, int count, const char *baz)
{
  static char buffer[1024];
  sprintf(buffer,
    "foo = %d, bar = %s, baz = %s, count = %d",
    self->foo, self->bar != NULL ? self->bar : "undef", baz != NULL ? baz : "undef", count
  );
  return buffer;
}