MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / malloc_conf_init

Function malloc_conf_init

deps/memkind/src/jemalloc/src/jemalloc.c:872–1192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 7

jemalloc_secure_getenvFunction · 0.70
malloc_conf_nextFunction · 0.70
extent_dss_prec_setFunction · 0.70
malloc_conf_errorFunction · 0.70
set_errnoFunction · 0.50

Tested by

no test coverage detected