src/java.base/unix/native/libjava/jni_util_md.c
Print this page
*** 24,33 ****
--- 24,34 ----
*/
#include <errno.h>
#include <string.h>
+ #include "jdk_strerror.h"
#include "jni.h"
#include "jni_util.h"
#include "dlfcn.h"
void* getProcessHandle() {
*** 53,70 ****
}
size_t
getLastErrorString(char *buf, size_t len)
{
! char *err;
! size_t n;
if (errno == 0 || len < 1) return 0;
! err = strerror(errno);
! n = strlen(err);
! if (n >= len)
! n = len - 1;
! strncpy(buf, err, n);
buf[n] = '\0';
return n;
}
--- 54,72 ----
}
size_t
getLastErrorString(char *buf, size_t len)
{
! char tmpbuf[1024];
! int n = 0;
!
if (errno == 0 || len < 1) return 0;
! jdk_strerror(errno, tmpbuf, (size_t) 1024);
! n = strlen(tmpbuf);
! if (n >= (int) len)
! n = (int) len - 1;
! strncpy(buf, tmpbuf, n);
buf[n] = '\0';
return n;
}