Path: blob/v3_openjdk/app_pojavlauncher/src/main/jni/environ/environ.c
2128 views
//1// Created by maks on 24.09.2022.2//34#include <stdlib.h>5#include <android/log.h>6#include <assert.h>7#include <string.h>8#include "environ.h"9#define TAG __FILE_NAME__10#include <log.h>1112struct pojav_environ_s *pojav_environ;13__attribute__((constructor)) void env_init() {14char* strptr_env = getenv("POJAV_ENVIRON");15if(strptr_env == NULL) {16LOGI("No environ found, creating...");17pojav_environ = malloc(sizeof(struct pojav_environ_s));18assert(pojav_environ);19memset(pojav_environ, 0 , sizeof(struct pojav_environ_s));20if(asprintf(&strptr_env, "%p", pojav_environ) == -1) abort();21setenv("POJAV_ENVIRON", strptr_env, 1);22free(strptr_env);23}else{24LOGI("Found existing environ: %s", strptr_env);25pojav_environ = (void*) strtoul(strptr_env, NULL, 0x10);26}27LOGI("%p", pojav_environ);28}2930