/* Change the size of a block allocated by `mmalloc'. */
-/* Copyright (c) 2010-2014. The SimGrid Team.
+/* Copyright (c) 2010-2019. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "mmprivate.h"
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
/* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for
* speed; some benchmarks seem to indicate that greater compactness is achieved by unconditionally allocating and
* copying to a new region. This module has incestuous knowledge of the internals of both mfree and mmalloc. */
if (size <= BLOCKSIZE / 2) { // Full block -> Fragment; no need to optimize for time
result = mmalloc(mdp, size);
- if (result != NULL) { // useless (mmalloc never returns NULL), but harmless
- memcpy(result, ptr, requested_size);
- mfree(mdp, ptr);
- return (result);
- }
+ memcpy(result, ptr, requested_size);
+ mfree(mdp, ptr);
+ return (result);
}
/* Full blocks -> Full blocks; see if we can hold it in place. */