This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git


The following commit(s) were added to refs/heads/main by this push:
     new d45550095 Remove remaining unused functions
d45550095 is described below

commit d4555009543c109c815fbef84ee19fc9407ff317
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Aug 27 12:03:10 2026 +0100

    Remove remaining unused functions
---
 native/include/tcn.h | 14 -------------
 native/src/error.c   | 28 -------------------------
 native/src/jnilib.c  | 59 ----------------------------------------------------
 3 files changed, 101 deletions(-)

diff --git a/native/include/tcn.h b/native/include/tcn.h
index d4900fb7b..bb5b0f015 100644
--- a/native/include/tcn.h
+++ b/native/include/tcn.h
@@ -160,13 +160,9 @@ struct tcn_socket_t {
 /* Private helper functions */
 void            tcn_Throw(JNIEnv *, const char *, ...);
 void            tcn_ThrowException(JNIEnv *, const char *);
-void            tcn_ThrowMemoryException(JNIEnv *, const char *, int, const 
char *);
 void            tcn_ThrowAPRException(JNIEnv *, apr_status_t);
 jstring         tcn_new_string(JNIEnv *, const char *);
 jstring         tcn_new_stringn(JNIEnv *, const char *, size_t);
-char           *tcn_get_string(JNIEnv *, jstring);
-char           *tcn_strdup(JNIEnv *, jstring);
-char           *tcn_pstrdup(JNIEnv *, jstring, apr_pool_t *);
 apr_status_t    tcn_load_finfo_class(JNIEnv *, jclass);
 apr_status_t    tcn_load_ainfo_class(JNIEnv *, jclass);
 unsigned long   tcn_get_thread_id(void);
@@ -185,9 +181,6 @@ unsigned long   tcn_get_thread_id(void);
 #define TCN_FREE_CSTRING(V)      \
     if (c##V) (*e)->ReleaseStringUTFChars(e, V, c##V)
 
-#define TCN_ALLOC_JSTRING(V)     \
-    char *c##V = tcn_get_string(e, (V))
-
 #define AJP_TO_JSTRING(V)   (*e)->NewStringUTF((e), (V))
 
 #define TCN_FREE_JSTRING(V)      \
@@ -196,13 +189,6 @@ unsigned long   tcn_get_thread_id(void);
             free(c##V);          \
     TCN_END_MACRO
 
-#define TCN_CHECK_ALLOCATED(x)                              \
-        if (x == NULL) {                                    \
-            tcn_ThrowMemoryException(e, __FILE__, __LINE__, \
-            "APR memory allocation failed");                \
-            goto cleanup;                                   \
-        } else (void)(0)
-
 #define TCN_THROW_IF_ERR(x, r)                  \
     TCN_BEGIN_MACRO                             \
         apr_status_t R = (x);                   \
diff --git a/native/src/error.c b/native/src/error.c
index 7a7eecc77..c69d30fe0 100644
--- a/native/src/error.c
+++ b/native/src/error.c
@@ -36,34 +36,6 @@ void tcn_ThrowException(JNIEnv *env, const char *msg)
 
 }
 
-void tcn_ThrowMemoryException(JNIEnv *env, const char *file, int line, const 
char *msg)
-{
-    jclass javaExceptionClass;
-    javaExceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
-    if (javaExceptionClass == NULL) {
-        fprintf(stderr, "Cannot find java/lang/OutOfMemoryError\n");
-        return;
-    }
-
-    if (file) {
-        char fmt[TCN_BUFFER_SZ];
-        char *f = (char *)(file + strlen(file) - 1);
-        while (f != file && '\\' != *f && '/' != *f) {
-            f--;
-        }
-        if (f != file) {
-            f++;
-        }
-        sprintf(fmt, "%s for [%04d@%s]", msg, line, f);
-        (*env)->ThrowNew(env, javaExceptionClass, &fmt[0]);
-    }
-    else
-        (*env)->ThrowNew(env, javaExceptionClass, msg);
-    (*env)->DeleteLocalRef(env, javaExceptionClass);
-
-}
-
-
 void tcn_Throw(JNIEnv *env, const char *fmt, ...)
 {
     char msg[TCN_BUFFER_SZ] = {'\0'};
diff --git a/native/src/jnilib.c b/native/src/jnilib.c
index 3a50d489d..fbd67da09 100644
--- a/native/src/jnilib.c
+++ b/native/src/jnilib.c
@@ -43,7 +43,6 @@ static JavaVM     *tcn_global_vm = NULL;
 
 static jclass    jString_class;
 static jmethodID jString_init;
-static jmethodID jString_getBytes;
 
 int tcn_parent_pid = 0;
 
@@ -76,8 +75,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
     TCN_LOAD_CLASS(env, jString_class, "java/lang/String", JNI_ERR);
     TCN_GET_METHOD(env, jString_class, jString_init,
                    "<init>", "([B)V", JNI_ERR);
-    TCN_GET_METHOD(env, jString_class, jString_getBytes,
-                   "getBytes", "()[B", JNI_ERR);
 
 #ifdef WIN32
     {
@@ -143,62 +140,6 @@ jstring tcn_new_string(JNIEnv *env, const char *str)
     }
 }
 
-char *tcn_get_string(JNIEnv *env, jstring jstr)
-{
-    jbyteArray bytes = NULL;
-    jthrowable exc;
-    char *result = NULL;
-
-    if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
-        return NULL; /* out of memory error */
-    }
-    bytes = (*env)->CallObjectMethod(env, jstr, jString_getBytes);
-    exc = (*env)->ExceptionOccurred(env);
-    if (!exc) {
-        jint len = (*env)->GetArrayLength(env, bytes);
-        result = (char *)malloc(len + 1);
-        if (result == NULL) {
-            TCN_THROW_OS_ERROR(env);
-            (*env)->DeleteLocalRef(env, bytes);
-            return 0;
-        }
-        (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *)result);
-        result[len] = '\0'; /* NULL-terminate */
-    }
-    else {
-        (*env)->DeleteLocalRef(env, exc);
-    }
-    (*env)->DeleteLocalRef(env, bytes);
-
-    return result;
-}
-
-char *tcn_strdup(JNIEnv *env, jstring jstr)
-{
-    char *result = NULL;
-    const char *cjstr;
-
-    cjstr = (const char *)((*env)->GetStringUTFChars(env, jstr, 0));
-    if (cjstr) {
-        result = strdup(cjstr);
-        (*env)->ReleaseStringUTFChars(env, jstr, cjstr);
-    }
-    return result;
-}
-
-char *tcn_pstrdup(JNIEnv *env, jstring jstr, apr_pool_t *pool)
-{
-    char *result = NULL;
-    const char *cjstr;
-
-    cjstr = (const char *)((*env)->GetStringUTFChars(env, jstr, 0));
-    if (cjstr) {
-        result = apr_pstrdup(pool, cjstr);
-        (*env)->ReleaseStringUTFChars(env, jstr, cjstr);
-    }
-    return result;
-}
-
 TCN_IMPLEMENT_CALL(jboolean, Library, initialize)(TCN_STDARGS)
 {
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to