You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/05/23 00:54:25 UTC
cvs commit: xml-xerces/c/src/xercesc/util PlatformUtils.hpp
neilg 2003/05/22 15:54:25
Modified: c/src/xercesc/util PlatformUtils.hpp
Log:
simultaneously make GCC happy and (hopefully) make it clearer what we actually use alignPointerForNewBlockAllocation() for in our code.
Revision Changes Path
1.16 +13 -7 xml-xerces/c/src/xercesc/util/PlatformUtils.hpp
Index: PlatformUtils.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PlatformUtils.hpp 22 May 2003 21:28:29 -0000 1.15
+++ PlatformUtils.hpp 22 May 2003 22:54:25 -0000 1.16
@@ -707,7 +707,7 @@
* The results of this function may be altered by defining
* XML_PLATFORM_NEW_BLOCK_ALIGNMENT.
*/
- static inline void* alignPointerForNewBlockAllocation(void* ptr);
+ static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);
private :
/** @name Private static methods */
@@ -794,8 +794,14 @@
// Calculate alignment required by platform for a new
// block allocation. We use this in our custom allocators
// to ensure that returned blocks are properly aligned.
-inline void*
-XMLPlatformUtils::alignPointerForNewBlockAllocation(void* ptr)
+// Note that, although this will take a pointer and return the position
+// at which it should be placed for correct alignment, in our code
+// we normally use size_t parameters to discover what the alignment
+// of header blocks should be. Thus, if this is to be
+// used for the former purpose, to make compilers happy
+// some casting will be necessary - neilg.
+inline size_t
+XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize)
{
// Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined
// as needed to dictate alignment requirements on a
@@ -808,12 +814,12 @@
#endif
// Calculate current alignment of pointer
- size_t current = (long)ptr % alignment;
+ size_t current = ptrSize % alignment;
// Adjust pointer alignment as needed
return (current == 0)
- ? ptr
- : ((char*)ptr + alignment - current);
+ ? ptrSize
+ : (ptrSize + alignment - current);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org