[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r116662: Further follow-up to last change in gmalloc
From: |
Ken Brown |
Subject: |
[Emacs-diffs] trunk r116662: Further follow-up to last change in gmalloc.c. |
Date: |
Tue, 04 Mar 2014 19:02:35 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 116662
revision-id: address@hidden
parent: address@hidden
committer: Ken Brown <address@hidden>
branch nick: trunk
timestamp: Tue 2014-03-04 14:02:49 -0500
message:
Further follow-up to last change in gmalloc.c.
* src/gmalloc.c (aligned_alloc): Clarify the code by making `adj'
represent the actual adjustment needed for alignment.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/gmalloc.c gmalloc.c-20091113204419-o5vbwnq5f7feedwu-1085
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-03-04 17:35:15 +0000
+++ b/src/ChangeLog 2014-03-04 19:02:49 +0000
@@ -1,3 +1,8 @@
+2014-03-04 Ken Brown <address@hidden>
+
+ * gmalloc.c (aligned_alloc): Clarify the code by making `adj'
+ represent the actual adjustment needed for alignment.
+
2014-03-04 Eli Zaretskii <address@hidden>
* gmalloc.c (aligned_alloc): Don't allocate more memory than
=== modified file 'src/gmalloc.c'
--- a/src/gmalloc.c 2014-03-04 17:35:15 +0000
+++ b/src/gmalloc.c 2014-03-04 19:02:49 +0000
@@ -1597,34 +1597,34 @@
/* Figure out how much we will need to pad this particular block
to achieve the required alignment. */
- adj = (uintptr_t) result % alignment;
- if (adj == 0)
- adj = alignment;
+ adj = alignment - (uintptr_t) result % alignment;
+ if (adj == alignment)
+ adj = 0;
- if (adj != 1)
+ if (adj != alignment - 1)
{
do
{
/* Reallocate the block with only as much excess as it
needs. */
free (result);
- result = malloc (size + alignment - adj);
+ result = malloc (size + adj);
if (result == NULL) /* Impossible unless interrupted. */
return NULL;
lastadj = adj;
- adj = (uintptr_t) result % alignment;
- if (adj == 0)
- adj = alignment;
+ adj = alignment - (uintptr_t) result % alignment;
+ if (adj == alignment)
+ adj = 0;
/* It's conceivable we might have been so unlucky as to get
a different block with weaker alignment. If so, this
block is too short to contain SIZE after alignment
correction. So we must try again and get another block,
slightly larger. */
- } while (adj < lastadj);
+ } while (adj > lastadj);
}
- if (adj != alignment)
+ if (adj != 0)
{
/* Record this block in the list of aligned blocks, so that `free'
can identify the pointer it is passed, which will be in the middle
@@ -1648,7 +1648,7 @@
if (l != NULL)
{
l->exact = result;
- result = l->aligned = (char *) result + alignment - adj;
+ result = l->aligned = (char *) result + adj;
}
UNLOCK_ALIGNED_BLOCKS ();
if (l == NULL)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r116662: Further follow-up to last change in gmalloc.c.,
Ken Brown <=