stas 2004/05/09 18:21:24
Modified: src/modules/perl modperl_error.c modperl_error.h
Log:
add a note that modperl_error_strerror return value must be copied unless
disposed of in the visible scope, since the next call to Perl_form will
overwrite that value.
Revision Changes Path
1.2 +2 -2 modperl-2.0/src/modules/perl/modperl_error.c
Index: modperl_error.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_error.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- modperl_error.c 4 May 2004 06:03:52 -0000 1.1
+++ modperl_error.c 10 May 2004 01:21:24 -0000 1.2
@@ -36,10 +36,10 @@
/* apache apr errors */
ptr = apr_strerror(rc, buf, sizeof(buf));
}
-
/* must copy the string and not return a pointer to the local
- * address */
+ * address. Using a single (per interpreter) static buffer.
+ */
return Perl_form(aTHX_ "%s", ptr);
}
1.2 +10 -0 modperl-2.0/src/modules/perl/modperl_error.h
Index: modperl_error.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_error.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- modperl_error.h 4 May 2004 06:03:52 -0000 1.1
+++ modperl_error.h 10 May 2004 01:21:24 -0000 1.2
@@ -19,6 +19,16 @@
/* to check whether $@ is set by ModPerl::Util::exit */
#define MODPERL_RC_EXIT APR_OS_START_USERERR + 0
+
+/**
+ * return the string representation of the error code
+ * @param rc error code
+ * @return the error string
+ *
+ * The return value must be immediately copied unless used only in a
+ * limited visible scope where it's clear that Perl_form() is not
+ * called again (which could happen indirectly). If unsure, copy.
+ */
char *modperl_error_strerror(pTHX_ apr_status_t rc);
void modperl_croak(pTHX_ apr_status_t rc, const char* func);