[Bf-blender-cvs] [4d29312c66d] master: Cleanup: trailing space guardedalloc & memutil

Campbell Barton noreply at git.blender.org
Thu Jan 24 06:22:07 CET 2019


Commit: 4d29312c66dd56498fbab35e2892944d33484461
Author: Campbell Barton
Date:   Thu Jan 24 16:20:16 2019 +1100
Branches: master
https://developer.blender.org/rB4d29312c66dd56498fbab35e2892944d33484461

Cleanup: trailing space guardedalloc & memutil

===================================================================

M	intern/guardedalloc/MEM_guardedalloc.h
M	intern/guardedalloc/intern/mallocn_guarded_impl.c
M	intern/guardedalloc/intern/mallocn_inline.h
M	intern/guardedalloc/intern/mmap_win.c
M	intern/guardedalloc/mmap_win.h
M	intern/guardedalloc/test/simpletest/memtest.c
M	intern/memutil/MEM_Allocator.h
M	intern/memutil/MEM_RefCounted.h
M	intern/memutil/MEM_RefCountedC-Api.h

===================================================================

diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 65650209711..c8a1441acf9 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -48,11 +48,11 @@
  *
  * There are currently no known issues with MEM. Note that there is a
  * second intern/ module with MEM_ prefix, for use in c++.
- * 
+ *
  * \subsection memdependencies Dependencies
  * - stdlib
  * - stdio
- * 
+ *
  * \subsection memdocs API Documentation
  * See \ref MEM_guardedalloc.h
  */
@@ -146,11 +146,11 @@ extern "C" {
 	extern void *(*MEM_mapallocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
 
 	/** Print a list of the names and sizes of all allocated memory
-	 * blocks. as a python dict for easy investigation */ 
+	 * blocks. as a python dict for easy investigation */
 	extern void (*MEM_printmemlist_pydict)(void);
 
 	/** Print a list of the names and sizes of all allocated memory
-	 * blocks. */ 
+	 * blocks. */
 	extern void (*MEM_printmemlist)(void);
 
 	/** calls the function on all allocated memory blocks. */
@@ -158,7 +158,7 @@ extern "C" {
 
 	/** Print statistics about memory usage */
 	extern void (*MEM_printmemlist_stats)(void);
-	
+
 	/** Set the callback function for error output. */
 	extern void (*MEM_set_error_callback)(void (*func)(const char *));
 
@@ -171,7 +171,7 @@ extern "C" {
 	/** Set thread locking functions for safe memory allocation from multiple
 	 * threads, pass NULL pointers to disable thread locking again. */
 	extern void (*MEM_set_lock_callback)(void (*lock)(void), void (*unlock)(void));
-	
+
 	/** Attempt to enforce OSX (or other OS's) to have malloc and stack nonzero */
 	extern void (*MEM_set_memory_debug)(void);
 
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index d09f1b83ad4..d6ae11637db 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -197,7 +197,7 @@ static const char *check_memlist(MemHead *memh);
 /* --------------------------------------------------------------------- */
 /* vars                                                                  */
 /* --------------------------------------------------------------------- */
-	
+
 
 static unsigned int totblock = 0;
 static size_t mem_in_use = 0, mmap_in_use = 0, peak_mem = 0;
@@ -289,7 +289,7 @@ bool MEM_guarded_consistency_check(void)
 	/* check_memlist starts from the front, and runs until it finds
 	 * the requested chunk. For this test, that's the last one. */
 	listend = membase->last;
-	
+
 	err_val = check_memlist(listend);
 
 	return (err_val == NULL);
@@ -316,7 +316,7 @@ size_t MEM_guarded_allocN_len(const void *vmemh)
 {
 	if (vmemh) {
 		const MemHead *memh = vmemh;
-	
+
 		memh--;
 		return memh->len;
 	}
@@ -328,7 +328,7 @@ size_t MEM_guarded_allocN_len(const void *vmemh)
 void *MEM_guarded_dupallocN(const void *vmemh)
 {
 	void *newp = NULL;
-	
+
 	if (vmemh) {
 		const MemHead *memh = vmemh;
 		memh--;
@@ -378,7 +378,7 @@ void *MEM_guarded_dupallocN(const void *vmemh)
 void *MEM_guarded_reallocN_id(void *vmemh, size_t len, const char *str)
 {
 	void *newp = NULL;
-	
+
 	if (vmemh) {
 		MemHead *memh = vmemh;
 		memh--;
@@ -485,7 +485,7 @@ static void print_memhead_backtrace(MemHead *memh)
 static void make_memhead_header(MemHead *memh, size_t len, const char *str)
 {
 	MemTail *memt;
-	
+
 	memh->tag1 = MEMTAG1;
 	memh->name = str;
 	memh->nextname = NULL;
@@ -522,7 +522,7 @@ void *MEM_guarded_mallocN(size_t len, const char *str)
 	MemHead *memh;
 
 	len = SIZET_ALIGN_4(len);
-	
+
 	memh = (MemHead *)malloc(len + sizeof(MemHead) + sizeof(MemTail));
 
 	if (LIKELY(memh)) {
@@ -785,7 +785,7 @@ void MEM_guarded_printmemlist_stats(void)
 		       (double)pb->len / 1024.0 / (double)pb->items, pb->name);
 	}
 	free(printblock);
-	
+
 	mem_unlock_thread();
 
 #ifdef HAVE_MALLOC_STATS
@@ -823,7 +823,7 @@ static void MEM_guarded_printmemlist_internal(int pydict)
 
 	membl = membase->first;
 	if (membl) membl = MEMNEXT(membl);
-	
+
 	if (pydict) {
 		print_error("# membase_debug.py\n");
 		print_error("membase = [\n");
@@ -856,7 +856,7 @@ static void MEM_guarded_printmemlist_internal(int pydict)
 		print_error("]\n\n");
 		print_error(mem_printmemlist_pydict_script);
 	}
-	
+
 	mem_unlock_thread();
 }
 
@@ -940,7 +940,7 @@ void MEM_guarded_freeN(void *vmemh)
 			return;
 		}
 	}
-	
+
 	memh--;
 	if (memh->tag1 == MEMFREE && memh->tag2 == MEMFREE) {
 		MemorY_ErroR(memh->name, "double free");
@@ -953,7 +953,7 @@ void MEM_guarded_freeN(void *vmemh)
 	{
 		memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + memh->len);
 		if (memt->tag3 == MEMTAG3) {
-			
+
 			memh->tag1 = MEMFREE;
 			memh->tag2 = MEMFREE;
 			memt->tag3 = MEMFREE;
diff --git a/intern/guardedalloc/intern/mallocn_inline.h b/intern/guardedalloc/intern/mallocn_inline.h
index 7f0fa2bd388..e662e3b7d72 100644
--- a/intern/guardedalloc/intern/mallocn_inline.h
+++ b/intern/guardedalloc/intern/mallocn_inline.h
@@ -53,4 +53,3 @@ MEM_INLINE bool MEM_size_safe_multiply(size_t a, size_t b, size_t *result)
 }
 
 #endif  /* __MALLOCN_INLINE_H__ */
-
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c
index 4f65c0a742f..031500d7420 100644
--- a/intern/guardedalloc/intern/mmap_win.c
+++ b/intern/guardedalloc/intern/mmap_win.c
@@ -4,7 +4,7 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -214,7 +214,7 @@ static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr)
 
 	if (ptr == NULL) return NULL;
 	if (listbase == NULL) return NULL;
-	
+
 	mm = (MemMap *)listbase->first;
 	while (mm) {
 		if (mm->mmap == ptr) {
diff --git a/intern/guardedalloc/mmap_win.h b/intern/guardedalloc/mmap_win.h
index a1959fed9f9..eb83f2926cc 100644
--- a/intern/guardedalloc/mmap_win.h
+++ b/intern/guardedalloc/mmap_win.h
@@ -4,7 +4,7 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,7 +29,7 @@
  *  \ingroup MEM
  *  \author Andrea Weikert
  */
- 
+
 #ifndef __MMAP_WIN_H__
 #define __MMAP_WIN_H__
 
@@ -57,4 +57,3 @@ void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset);
 intptr_t munmap(void *ptr, size_t size);
 
 #endif
-
diff --git a/intern/guardedalloc/test/simpletest/memtest.c b/intern/guardedalloc/test/simpletest/memtest.c
index d306337d0ab..eb01f5a1e63 100644
--- a/intern/guardedalloc/test/simpletest/memtest.c
+++ b/intern/guardedalloc/test/simpletest/memtest.c
@@ -60,10 +60,10 @@ int main(int argc, char *argv[])
 
 	/* ----------------------------------------------------------------- */
 	switch (argc) {
-	case 2:		
+	case 2:
 		verbose = atoi(argv[1]);
 		if (verbose < 0) verbose = 0;
-		break;		
+		break;
 	case 1:
 	default:
 		verbose = 0;
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 	/* ----------------------------------------------------------------- */
 	/* flush mem lib output to stderr */
 	MEM_set_error_callback(mem_error_cb);
-	
+
 	for (i = 0; i < NUM_BLOCKS; i++) {
 		int blocksize = 10000;
 		char tagstring[1000];
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
 		else {
 			fprintf(stderr, "|--* Memory tested as good (as it should be)\n|\n");
 		}
-	} 
+	}
 
 	for (i = 0; i < NUM_BLOCKS; i++) {
 		MEM_freeN(p[i]);
@@ -124,11 +124,11 @@ int main(int argc, char *argv[])
 	for (i = 0; i< 1000; i++,ip++) *ip = i+1;
 	ip = (int*) p[6];
 	*(ip+10005) = 0;
-	
+
 	retval = MEM_consistency_check();
 
 	/* the test should have failed */
-	error_status |= !retval;		
+	error_status |= !retval;
 	if (verbose) {
 		if (retval) {
 			fprintf(stderr, "|--* Memory test failed (as it should be)\n");
@@ -136,8 +136,8 @@ int main(int argc, char *argv[])
 		else {
 			fprintf(stderr, "|--* Memory test FAILED to find corrupted blocks \n");
 		}
-	} 
-	
+	}
+
 	for (i = 0; i < NUM_BLOCKS; i++) {
 		MEM_freeN(p[i]);
 	}
@@ -146,7 +146,7 @@ int main(int argc, char *argv[])
 	if (verbose && error_status) {
 		fprintf(stderr,"|--* Memory was corrupted\n");
 	}
-	/* ----------------------------------------------------------------- */	
+	/* ----------------------------------------------------------------- */
 	if (verbose) {
 		if (error_status) {
 			fprintf(stderr,"|\n|--* Errors were detected\n");
@@ -154,10 +154,8 @@ int main(int argc, char *argv[])
 		else {
 			fprintf(stderr,"|\n|--* Test exited succesfully\n");
 		}
-		
+
 		fprintf(stderr,"|\n*** Finished test\n\n");
 	}
 	return error_status;
 }
-
-
diff --git a/intern/memutil/MEM_Allocator.h b/intern/memutil/MEM_Allocator.h
index 2bcdf3a6fa5..84c6452bbb0 100644
--- a/intern/memutil/MEM_Allocator.h
+++ b/intern/memutil/MEM_Allocator.h
@@ -43,8 +43,8 @@ struct MEM_Allocator
 	typedef _Tp        value_type;
 
 	template<typename _Tp1>
-        struct rebind { 
-		typedef MEM_Allocator<_Tp1> other; 
+        struct rebind {
+		typedef MEM_Allocator<_Tp1> other;
 	};
 
 	MEM_Allocator() throw() {}
@@ -75,16 +75,16 @@ struct MEM_Allocator
 		MEM_freeN(__p);
 	}
 
-	size_type max_size() const throw() { 
-		return size_t(-1) / sizeof(_Tp); 
+	size_type max_size() const throw() {
+		return size_t(-1) / sizeof(_Tp);
 	}
 
-	void construct(pointer __p, const _Tp& __val) { 
-		new(__p) _Tp(__val); 
+	void construct(pointer __p, const _Tp& __val) {
+		new(__p) _Tp(__val);
 	}
 
-	void destroy(pointer __p) { 
-		__p->~_Tp(); 
+	voi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list