diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2019-09-17 21:53:05 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2019-09-17 21:53:05 +0000 |
commit | bcdf18e4dd92f592617c35edbc9ffbb2817bd36c (patch) | |
tree | d408e019b135df92eb3f6860333865b9c9064b5c /archive | |
parent | eaa9d929aba1cc812418582c779731bcde2adf68 (diff) | |
download | sg3_utils-bcdf18e4dd92f592617c35edbc9ffbb2817bd36c.tar.gz |
sync with fixes from Redhat, via github; remove testing/Makefile.cplus and testing/Makefile.cplus_fb
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@832 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'archive')
-rw-r--r-- | archive/align_b4_memalign.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/archive/align_b4_memalign.c b/archive/align_b4_memalign.c index 87602027..1cd4032d 100644 --- a/archive/align_b4_memalign.c +++ b/archive/align_b4_memalign.c @@ -1,5 +1,6 @@ -/* Code fragment of how to get a buffer of heap that has a specific - * alignment, typically 'page' size which is 4096 bytes. */ +/* Code fragment of how to get a buffer from the heap that has a specific + * alignment. The typical alignment is to a "page" whose size is often + * 4096 bytes. */ uint8_t * wrkBuff; /* will get pointer to heap allocation */ uint8_t * wrkPos; /* will get aligned pointer within wrkBuff */ @@ -17,3 +18,7 @@ /* perhaps use posix_memalign() instead. Yes but not always available */ wrkBuff = (uint8_t *)malloc(sz_of_aligned + psz); wrkPos = (uint8_t *)(((sg_uintptr_t)wrkBuff + psz - 1) & (~(psz - 1))); + +/* The disadvantage of this approach is that it needs both wrkBuff and wrkPos + * to be held by the application. The wrkBuff is only needed for the + * corresponding free(), all other uses should be via wrkPos. */ |