1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
2 This file was then part of the GNU C Library. */
4 /* Copyright (c) 2010. The SimGrid Team.
5 * All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "mmprivate.h"
13 mmemalign (void *md, size_t alignment, size_t size)
16 unsigned long int adj;
20 if ((result = mmalloc (md, size + alignment - 1)) != NULL)
22 adj = RESIDUAL (result, alignment);
26 for (l = mdp -> aligned_blocks; l != NULL; l = l -> next)
28 if (l -> aligned == NULL)
30 /* This slot is free. Use it. */
36 l = (struct alignlist *) mmalloc (md, sizeof (struct alignlist));
42 l -> next = mdp -> aligned_blocks;
43 mdp -> aligned_blocks = l;
46 result = l -> aligned = (char*) result + alignment - adj;