Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/PojavLauncher
Path: blob/v3_openjdk/app_pojavlauncher/src/main/jni/environ/environ.c
2128 views
1
//
2
// Created by maks on 24.09.2022.
3
//
4
5
#include <stdlib.h>
6
#include <android/log.h>
7
#include <assert.h>
8
#include <string.h>
9
#include "environ.h"
10
#define TAG __FILE_NAME__
11
#include <log.h>
12
13
struct pojav_environ_s *pojav_environ;
14
__attribute__((constructor)) void env_init() {
15
char* strptr_env = getenv("POJAV_ENVIRON");
16
if(strptr_env == NULL) {
17
LOGI("No environ found, creating...");
18
pojav_environ = malloc(sizeof(struct pojav_environ_s));
19
assert(pojav_environ);
20
memset(pojav_environ, 0 , sizeof(struct pojav_environ_s));
21
if(asprintf(&strptr_env, "%p", pojav_environ) == -1) abort();
22
setenv("POJAV_ENVIRON", strptr_env, 1);
23
free(strptr_env);
24
}else{
25
LOGI("Found existing environ: %s", strptr_env);
26
pojav_environ = (void*) strtoul(strptr_env, NULL, 0x10);
27
}
28
LOGI("%p", pojav_environ);
29
}
30