Просмотр исходного кода

Fixed memory manager still using SVN revision

Lemongrass3110 7 лет назад
Родитель
Сommit
37f7fc5708
2 измененных файлов с 12 добавлено и 7 удалено
  1. 3 5
      src/common/core.cpp
  2. 9 2
      src/common/malloc.c

+ 3 - 5
src/common/core.cpp

@@ -148,12 +148,10 @@ void signals_init (void) {
 }
 #endif
 
+const char* get_svn_revision(void) {
 #ifdef SVNVERSION
-const char *get_svn_revision(void) {
-		return EXPAND_AND_QUOTE(SVNVERSION);
-	}
+	return EXPAND_AND_QUOTE(SVNVERSION);
 #else// not SVNVERSION
-const char* get_svn_revision(void) {
 	static char svn_version_buffer[16] = "";
 	FILE *fp;
 
@@ -244,8 +242,8 @@ const char* get_svn_revision(void) {
 	// fallback
 	svn_version_buffer[0] = UNKNOWN_VERSION;
 	return svn_version_buffer;
-}
 #endif
+}
 
 // Grabs the hash from the last time the user updated their working copy (last pull)
 const char *get_git_hash (void) {

+ 9 - 2
src/common/malloc.c

@@ -529,6 +529,7 @@ static void memmgr_log (char *buf)
 {
 	if( !log_fp )
 	{
+		const char* version;
 		time_t raw;
 		struct tm* t;
 
@@ -537,8 +538,14 @@ static void memmgr_log (char *buf)
 
 		time(&raw);
 		t = localtime(&raw);
-		fprintf(log_fp, "\nMemory manager: Memory leaks found at %d/%02d/%02d %02dh%02dm%02ds (Revision %s).\n",
-			(t->tm_year+1900), (t->tm_mon+1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, get_svn_revision());
+
+		if( ( version = get_git_hash() ) && version[0] != UNKNOWN_VERSION ){
+			fprintf(log_fp, "\nMemory manager: Memory leaks found at %d/%02d/%02d %02dh%02dm%02ds (Git Hash %s).\n", (t->tm_year+1900), (t->tm_mon+1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, version );
+		}else if( ( version = get_svn_revision() ) && version[0] != UNKNOWN_VERSION ){
+			fprintf(log_fp, "\nMemory manager: Memory leaks found at %d/%02d/%02d %02dh%02dm%02ds (SVN Revision %s).\n", (t->tm_year + 1900), (t->tm_mon + 1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, version );
+		}else{
+			fprintf(log_fp, "\nMemory manager: Memory leaks found at %d/%02d/%02d %02dh%02dm%02ds (Unknown version).\n", (t->tm_year + 1900), (t->tm_mon + 1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec );
+		}
 	}
 	fprintf(log_fp, "%s", buf);
 	return;