RFR-8008118
Martin Buchholz
martinrb at google.com
Wed Mar 27 03:44:21 UTC 2013
Of course, I made a (harmless) mistake in xstrdup. There is no need to
throw since NEW does that already.
+static char*
+xstrdup(JNIEnv *env, const char *s)
+{
+ size_t size = strlen(s) + 1;
+ char *p = NEW(char, size);
+ if (p != NULL)
+ memcpy(p, s, size);
+ return p;
+}
+
On Tue, Mar 26, 2013 at 6:58 PM, Christos Zoulas <christos at zoulas.com>wrote:
> On Mar 26, 6:13pm, martinrb at google.com (Martin Buchholz) wrote:LGTM,
> only question is why error from one allocation throws and from the
> other does not? I would move the throw after the:
>
> if (splitpath == NULL || pathv == NULL) {
>
>
The rule is: failed allocation throws, caller needs to check for and
propagate NULL.
> This way we don't need to pass env to xstrdup(). Now you are going to make
> me grep on how many xstrdup()'s are in the tree :-)
>
More information about the core-libs-dev
mailing list