cvs: pecl /ffi ffi_library.c ffi_parser.y ffi_struct.c
| From: | Wez Furlong | Date: | Fri, 09 Jan 2004 23:41:55 +0000 |
| Subject: | cvs: pecl /ffi ffi_library.c ffi_parser.y ffi_struct.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-725@lists.php.net to get a copy of this message | ||
wez Fri Jan 9 18:41:55 2004 EDT
Modified files:
/pecl/ffi ffi_library.c ffi_parser.y ffi_struct.c
Log:
Tweaks so that it builds under linux:
<?php
$ffi = new ffi(<<<EOD
[lib='libc.so.6'] int time(int *tv);
EOD
);
echo $ffi->time(null);
?>
Index: pecl/ffi/ffi_library.c
diff -u pecl/ffi/ffi_library.c:1.1 pecl/ffi/ffi_library.c:1.2
--- pecl/ffi/ffi_library.c:1.1 Fri Jan 9 17:30:09 2004
+++ pecl/ffi/ffi_library.c Fri Jan 9 18:41:55 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ffi_library.c,v 1.1 2004/01/09 22:30:09 wez Exp $ */
+/* $Id: ffi_library.c,v 1.2 2004/01/09 23:41:55 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -462,6 +462,10 @@
efree(return_value_buf);
}
+ if (need_free) {
+ efree(need_free);
+ }
+
return ret;
}
Index: pecl/ffi/ffi_parser.y
diff -u pecl/ffi/ffi_parser.y:1.1 pecl/ffi/ffi_parser.y:1.2
--- pecl/ffi/ffi_parser.y:1.1 Fri Jan 9 17:30:09 2004
+++ pecl/ffi/ffi_parser.y Fri Jan 9 18:41:55 2004
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ffi_parser.y,v 1.1 2004/01/09 22:30:09 wez Exp $ */
+/* $Id: ffi_parser.y,v 1.2 2004/01/09 23:41:55 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -40,6 +40,8 @@
#define IDENT_EQUALS(str, v) (v.len == sizeof(str)-1 && memcmp(str, v.val, v.len) == 0)
+static char *yyTokenName[];
+
static const char *get_ident_string(php_ffi_ident id)
{
static char idbuf[256];
@@ -86,7 +88,7 @@
sprintf(tokbuf, "identifier: %s", get_ident_string(t.ident));
break;
default:
- sprintf(tokbuf, "token: %s", php_ffi_parserTokenName(major));
+ sprintf(tokbuf, "token: %s", yyTokenName[major]);
}
return tokbuf;
}
@@ -178,8 +180,8 @@
{
int i;
php_ffi_type_def tdef = {0}, *rettype;
- CTX_TSRMLS_FETCH();
long offset = 0;
+ CTX_TSRMLS_FETCH();
tdef.nfields = ctx->n_args;
tdef.ffi_t.elements = emalloc((tdef.nfields + 1) * sizeof(ffi_type *));
Index: pecl/ffi/ffi_struct.c
diff -u pecl/ffi/ffi_struct.c:1.1 pecl/ffi/ffi_struct.c:1.2
--- pecl/ffi/ffi_struct.c:1.1 Fri Jan 9 17:30:09 2004
+++ pecl/ffi/ffi_struct.c Fri Jan 9 18:41:55 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ffi_struct.c,v 1.1 2004/01/09 22:30:09 wez Exp $ */
+/* $Id: ffi_struct.c,v 1.2 2004/01/09 23:41:55 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -337,8 +337,14 @@
case FFI_TYPE_VOID: *mem = NULL; return 1;
case FFI_TYPE_POINTER:
/* TODO: should verify that we are really looking for a string */
- convert_to_string(val);
- *mem = &Z_STRVAL_P(val);
+ if (Z_TYPE_P(val) == IS_NULL) {
+ *mem = emalloc(sizeof(void*));
+ *(void**)*mem = NULL;
+ *need_free = 1;
+ } else {
+ convert_to_string(val);
+ *mem = &Z_STRVAL_P(val);
+ }
return 1;
case FFI_TYPE_INT:
convert_to_long(val);