mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8303814: getLastErrorString should avoid charset conversions
Reviewed-by: naoto, cjplummer, rriggs
This commit is contained in:
parent
830fd41346
commit
baf11e734f
8 changed files with 106 additions and 129 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -60,12 +60,13 @@ void buildJniFunctionName(const char *sym, const char *cname,
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT size_t JNICALL
|
||||
getLastErrorString(char *buf, size_t len)
|
||||
jstring
|
||||
getLastErrorString(JNIEnv *env)
|
||||
{
|
||||
if (errno == 0 || len < 1) return 0;
|
||||
getErrorString(errno, buf, len);
|
||||
return strlen(buf);
|
||||
char buf[256] = {0};
|
||||
if (errno == 0) return NULL;
|
||||
getErrorString(errno, buf, sizeof(buf));
|
||||
return (buf[0] != 0) ? JNU_NewStringPlatform(env, buf) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT int JNICALL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue