diotalevi has asked for the wisdom of the Perl Monks concerning the following question:
This snippet show the original C code from zopen.c calling read() and then my substitute in some Inline::C code using perl's read(). I don't know that it is "ok" to call perl builtins from Inline::C by calling CORE:: functions. So is it? And is there a better way to write this?
/* Check the magic number */ if (read(zs->zs_fh, header, sizeof(header)) != sizeof(header) || memcmp(header, z_magic, sizeof(z_magic)) != 0) { errno = EFTYPE; return (-1); } /* Check the magic number */ Inline_Stack_Reset; Inline_Stack_Push(zs->zs_fh); /* a SV* of a IO handle passed in ea +rlier */ Inline_Stack_Push(header); Inline_Stack_Push(sizeof(header)); perl_call_pv("CORE::read",G_SCALAR); read_rval = (ssize_t)POPi; Inline_Stack_Done; if (read_rval != sizeof(header) || memcmp(header, z_magic, sizeof(z_magic)) != 0) { errno = EFTYPE; return (-1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling builtin functions from Inline::C
by derby (Abbot) on Aug 04, 2003 at 12:35 UTC | |
by diotalevi (Canon) on Aug 04, 2003 at 14:20 UTC | |
|
Re: Calling builtin functions from Inline::C
by mpeppler (Vicar) on Aug 04, 2003 at 13:40 UTC | |
|
Re: Calling builtin functions from Inline::C
by diotalevi (Canon) on Aug 04, 2003 at 17:01 UTC |