MCPcopy Create free account
hub / github.com/F-Stack/f-stack / malloc_conf_init

Function malloc_conf_init

app/redis-6.2.6/deps/jemalloc/src/jemalloc.c:871–1246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

869}
870
871static void
872malloc_conf_init(void) {
873 unsigned i;
874 char buf[PATH_MAX + 1];
875 const char *opts, *k, *v;
876 size_t klen, vlen;
877
878 for (i = 0; i < 4; i++) {
879 /* Get runtime configuration. */
880 switch (i) {
881 case 0:
882 opts = config_malloc_conf;
883 break;
884 case 1:
885 if (je_malloc_conf != NULL) {
886 /*
887 * Use options that were compiled into the
888 * program.
889 */
890 opts = je_malloc_conf;
891 } else {
892 /* No configuration specified. */
893 buf[0] = '\0';
894 opts = buf;
895 }
896 break;
897 case 2: {
898 ssize_t linklen = 0;
899#ifndef _WIN32
900 int saved_errno = errno;
901 const char *linkname =
902# ifdef JEMALLOC_PREFIX
903 "/etc/"JEMALLOC_PREFIX"malloc.conf"
904# else
905 "/etc/malloc.conf"
906# endif
907 ;
908
909 /*
910 * Try to use the contents of the "/etc/malloc.conf"
911 * symbolic link's name.
912 */
913 linklen = readlink(linkname, buf, sizeof(buf) - 1);
914 if (linklen == -1) {
915 /* No configuration specified. */
916 linklen = 0;
917 /* Restore errno. */
918 set_errno(saved_errno);
919 }
920#endif
921 buf[linklen] = '\0';
922 opts = buf;
923 break;
924 } case 3: {
925 const char *envname =
926#ifdef JEMALLOC_PREFIX
927 JEMALLOC_CPREFIX"MALLOC_CONF"
928#else

Callers 1

Calls 9

set_errnoFunction · 0.85
jemalloc_secure_getenvFunction · 0.85
malloc_conf_nextFunction · 0.85
strncmpFunction · 0.85
malloc_conf_errorFunction · 0.85
extent_dss_prec_setFunction · 0.85
strncpyFunction · 0.85

Tested by

no test coverage detected