Revision: 1102
Author: [email protected]
Date: Mon Mar 8 01:46:08 2010
Log: Convert output_tag_int, output_nv and output_str to return the written
count.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1102
Modified:
/trunk/NYTProf.h
/trunk/NYTProf.xs
=======================================
--- /trunk/NYTProf.h Wed Feb 17 08:35:39 2010
+++ /trunk/NYTProf.h Mon Mar 8 01:46:08 2010
@@ -20,9 +20,9 @@
library file, with a public API, the XS interface adapted to use that
API,
and these 3 return to being static functions, within that library. */
-void output_tag_int(NYTP_file file, unsigned char tag, unsigned int);
-void output_str(NYTP_file file, const char *str, I32 len);
-void output_nv(NYTP_file file, NV nv);
+size_t output_tag_int(NYTP_file file, unsigned char tag, unsigned int);
+size_t output_str(NYTP_file file, const char *str, I32 len);
+size_t output_nv(NYTP_file file, NV nv);
#define NYTP_TAG_NO_TAG '\0' /* Used as a flag to mean "no tag"
*/
#define output_int(fh, i) output_tag_int((fh), NYTP_TAG_NO_TAG,
(unsigned int)(i))
=======================================
--- /trunk/NYTProf.xs Mon Mar 8 01:46:03 2010
+++ /trunk/NYTProf.xs Mon Mar 8 01:46:08 2010
@@ -485,17 +485,28 @@
}
-void
+size_t
output_str(NYTP_file file, const char *str, I32 len) { /* negative len
signifies utf8 */
unsigned char tag = NYTP_TAG_STRING;
+ size_t retval;
+ size_t total;
+
if (len < 0) {
tag = NYTP_TAG_STRING_UTF8;
len = -len;
}
if (trace_level >= 10)
logwarn("output_str('%.*s', %d)\n", (int)len, str, (int)len);
- output_tag_int(file, tag, len);
- NYTP_write(file, str, len);
+
+ total = retval = output_tag_int(file, tag, len);
+ if (retval <= 0)
+ return retval;
+
+ total += retval = NYTP_write(file, str, len);
+ if (retval <= 0)
+ return retval;
+
+ return total;
}
@@ -981,7 +992,7 @@
* "In bytes" means output the number in binary, using the least number of
bytes
* possible. All numbers are positive. Use sign slot as a marker
*/
-void
+size_t
output_tag_int(NYTP_file file, unsigned char tag, unsigned int i)
{
U8 buffer[6];
@@ -1016,7 +1027,7 @@
*p++ = (U8)(i >> 8);
*p++ = (U8)i;
}
- NYTP_write(file, buffer, p - buffer);
+ return NYTP_write(file, buffer, p - buffer);
}
@@ -1035,10 +1046,10 @@
* Output a double precision float via a simple binary write of the memory.
* (Minor portbility issues are seen as less important than speed and
space.)
*/
-void
+size_t
output_nv(NYTP_file file, NV nv)
{
- NYTP_write(file, (unsigned char *)&nv, sizeof(NV));
+ return NYTP_write(file, (unsigned char *)&nv, sizeof(NV));
}
--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]