@@ -377,7 +377,7 @@ static void handle_browse(struct mg_connection *c, struct mg_http_message *hm) {
377377 char path [1024 ] = {0 };
378378 if (!get_query_param (hm -> query , "path" , path , (int )sizeof (path )) || path [0 ] == '\0' ) {
379379 /* Default to home directory */
380- const char * home = getenv ( "HOME" );
380+ const char * home = cbm_get_home_dir ( );
381381 if (home )
382382 snprintf (path , sizeof (path ), "%s" , home );
383383 else
@@ -452,9 +452,9 @@ static void handle_adr_get(struct mg_connection *c, struct mg_http_message *hm)
452452 return ;
453453 }
454454
455- const char * home = getenv ( "HOME" );
455+ const char * home = cbm_get_home_dir ( );
456456 if (!home )
457- home = "/tmp" ;
457+ home = cbm_tmpdir () ;
458458 char db_path [1024 ];
459459 snprintf (db_path , sizeof (db_path ), "%s/.cache/codebase-memory-mcp/%s.db" , home , name );
460460
@@ -545,9 +545,9 @@ static void handle_adr_save(struct mg_connection *c, struct mg_http_message *hm)
545545 const char * proj = yyjson_get_str (v_proj );
546546 const char * content = yyjson_get_str (v_content );
547547
548- const char * home = getenv ( "HOME" );
548+ const char * home = cbm_get_home_dir ( );
549549 if (!home )
550- home = "/tmp" ;
550+ home = cbm_tmpdir () ;
551551 char db_path [1024 ];
552552 snprintf (db_path , sizeof (db_path ), "%s/.cache/codebase-memory-mcp/%s.db" , home , proj );
553553
@@ -832,9 +832,9 @@ static void handle_delete_project(struct mg_connection *c, struct mg_http_messag
832832 return ;
833833 }
834834
835- const char * home = getenv ( "HOME" ); // NOLINT(concurrency-mt-unsafe)
835+ const char * home = cbm_get_home_dir ();
836836 if (!home )
837- home = "/tmp" ;
837+ home = cbm_tmpdir () ;
838838 char db_path [1024 ];
839839 snprintf (db_path , sizeof (db_path ), "%s/.cache/codebase-memory-mcp/%s.db" , home , name );
840840
@@ -870,9 +870,9 @@ static void handle_project_health(struct mg_connection *c, struct mg_http_messag
870870 return ;
871871 }
872872
873- const char * home = getenv ( "HOME" ); // NOLINT(concurrency-mt-unsafe)
873+ const char * home = cbm_get_home_dir ();
874874 if (!home )
875- home = "/tmp" ;
875+ home = cbm_tmpdir () ;
876876 char db_path [1024 ];
877877 snprintf (db_path , sizeof (db_path ), "%s/.cache/codebase-memory-mcp/%s.db" , home , name );
878878
@@ -928,9 +928,9 @@ static void handle_layout(struct mg_connection *c, struct mg_http_message *hm) {
928928 }
929929
930930 /* Open a read-only store for this project */
931- const char * home = getenv ( "HOME" ); // NOLINT(concurrency-mt-unsafe)
931+ const char * home = cbm_get_home_dir ();
932932 if (!home )
933- home = "/tmp" ;
933+ home = cbm_tmpdir () ;
934934 char db_path [1024 ];
935935 snprintf (db_path , sizeof (db_path ), "%s/.cache/codebase-memory-mcp/%s.db" , home , project );
936936
0 commit comments