Skip to content

Commit e10880a

Browse files
committed
smolscale: Don't offset scratch pointers if already aligned
1 parent ea18ac4 commit e10880a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

chafa/internal/smolscale/smolscale-private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ typedef unsigned int SmolBool;
101101

102102
/* Pointer to beginning of storage is stored in *r. This must be passed to smol_free() later. */
103103
#define smol_alloc_aligned_to(s, a, r) \
104-
({ void *p; *(r) = _SMOL_ALLOC ((s) + (a)); p = (void *) (((uintptr_t) (*(r)) + (a)) & ~((a) - 1)); (p); })
104+
({ void *p; *(r) = _SMOL_ALLOC ((s) + (a) - 1); \
105+
p = (void *) (((uintptr_t) (*(r)) + (a) - 1) & ~(uintptr_t) ((a) - 1)); (p); })
105106
#define smol_alloc_aligned(s, r) smol_alloc_aligned_to ((s), SMOL_ALIGNMENT, (r))
106107
#define smol_free(p) _SMOL_FREE(p)
107108

0 commit comments

Comments
 (0)