Revision: 1057
Author: [email protected]
Date: Wed Feb 17 08:35:39 2010
Log: Add casts and consts to get NYTProf to build (and pass tests) under g++.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1057

Modified:
 /trunk/FileHandle.xs
 /trunk/NYTProf.h
 /trunk/NYTProf.xs

=======================================
--- /trunk/FileHandle.xs        Tue Feb  9 06:52:22 2010
+++ /trunk/FileHandle.xs        Wed Feb 17 08:35:39 2010
@@ -323,7 +323,7 @@
         while (1) {
const unsigned char *const p = ifile->large_buffer + ifile->count; const unsigned int remaining = ((unsigned char *) ifile->zs.next_out) - p;
-            unsigned char *const nl = memchr(p, '\n', remaining);
+ unsigned char *const nl = (unsigned char *)memchr(p, '\n', remaining);
             size_t got;
             size_t want;
             size_t extra;
@@ -338,7 +338,7 @@
             if (extra > len - prev_len) {
                 prev_len = len;
                 len += extra;
-                buffer = saferealloc(buffer, len);
+                buffer = (char *)saferealloc(buffer, len);
             }

             got = NYTP_read_unchecked(ifile, buffer + prev_len, want);
@@ -377,7 +377,7 @@
         }
         prev_len = len - 1; /* -1 to take off the '\0' at the end */
         len *= 2;
-        buffer = saferealloc(buffer, len);
+        buffer = (char *)saferealloc(buffer, len);
     }
     *buffer_p = buffer;
     *len_p = len;
=======================================
--- /trunk/NYTProf.h    Fri Dec 18 09:04:12 2009
+++ /trunk/NYTProf.h    Wed Feb 17 08:35:39 2010
@@ -21,7 +21,7 @@
    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, char *str, I32 len);
+void output_str(NYTP_file file, const char *str, I32 len);
 void output_nv(NYTP_file file, NV nv);

#define NYTP_TAG_NO_TAG '\0' /* Used as a flag to mean "no tag" */
=======================================
--- /trunk/NYTProf.xs   Mon Feb  8 06:49:33 2010
+++ /trunk/NYTProf.xs   Wed Feb 17 08:35:39 2010
@@ -484,7 +484,7 @@


 void
-output_str(NYTP_file file, char *str, I32 len) { /* negative len signifies utf8 */ +output_str(NYTP_file file, const char *str, I32 len) { /* negative len signifies utf8 */
     unsigned char tag = NYTP_TAG_STRING;
     if (len < 0) {
         tag = NYTP_TAG_STRING_UTF8;
@@ -1727,7 +1727,7 @@

     CV           *called_cv;
     int           called_cv_depth;
-    char         *called_is_xs;         /* NULL, "xsub", or "syop" */
+    const char   *called_is_xs;         /* NULL, "xsub", or "syop" */
     char         *called_subpkg_pv;
     SV           *called_subnam_sv;
/* ensure all items are initialized in first phase of pp_subcall_profiler */
@@ -2123,7 +2123,7 @@
     subr_entry_t *subr_entry;
     I32 prev_subr_entry_ix;
     subr_entry_t *caller_subr_entry;
-    char *found_caller_by;
+    const char *found_caller_by;
     char *file;

     /* allocate struct to save stack (very efficient) */
@@ -2490,7 +2490,7 @@
     }
     else {
         char *stash_name = NULL;
-        char *is_xs = NULL;
+        const char *is_xs = NULL;

         if (op_type == OP_GOTO) {
             /* use the called_cv that was the arg to the goto op */
@@ -3234,7 +3234,7 @@
             int trace = (trace_level >= 3);

             unsigned int fid = 0, line = 0;
-            char *fid_line_delim = "[";
+            const char *fid_line_delim = "[";
char *fid_line_start = rninstr(caller_subname, caller_subname+caller_subname_len, fid_line_delim, fid_line_delim+1);
             if (!fid_line_start) {
                 logwarn("bad fid_lines_hv key '%s'\n", caller_subname);
@@ -3345,7 +3345,7 @@
         for (line = 1; line <= lines; ++line) { /* lines start at 1 */
             SV **svp = av_fetch(src_av, line, 0);
             STRLEN len = 0;
-            char *src = (svp) ? SvPV(*svp, len) : "";
+            const char *src = (svp) ? SvPV(*svp, len) : "";
             /* outputting the tag and fid for each (non empty) line
              * is a little inefficient, but not enough to worry about */
             output_tag_int(out, NYTP_TAG_SRC_LINE, e->id);
@@ -3445,7 +3445,7 @@

/* Assumption is that space is the least common character in a filename. */

-    for (; len >= 8 && (first_space = memchr(start, ' ', len));
+    for (; len >= 8 && (first_space = (char *)memchr(start, ' ', len));
          (len -= first_space +1 - start), (start = first_space + 1)) {
         char *first_digit;
         char *close;
@@ -3616,7 +3616,7 @@
SV *cb_args[12]; /* must be large enough for the largest callback argument list */

     size_t buffer_len = MAXPATHLEN * 2;
-    char *buffer = safemalloc(buffer_len);
+    char *buffer = (char *)safemalloc(buffer_len);

     av_extend(fid_fileinfo_av, 64);               /* grow them up front. */
     av_extend(fid_srclines_av, 64);
@@ -4223,7 +4223,7 @@
                     /* probably EOF */
                     croak("Profile format error reading attribute");
                 --end; /* End, as returned, points 1 after the \n  */
- if ((NULL == (value = memchr(buffer, '=', end - buffer)))) { + if ((NULL == (value = (char *)memchr(buffer, '=', end - buffer)))) {
                     logwarn("attribute malformed '%s'\n", buffer);
                     continue;
                 }

--
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]

Reply via email to