<HTML><BODY><div> </div><div><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16088811961215889925_BODY"><div class="cl_883667"><div class="WordSection1_mr_css_attr"><p class="MsoNormal_mr_css_attr">>> I don't understand. So you can make the factor smaller than it was</p><p class="MsoNormal_mr_css_attr">>> requested? What is the point in configuring the factor then?</p><p class="MsoNormal_mr_css_attr">> 9. The user configures the allocation factor, the actual factor may differ,</p><p class="MsoNormal_mr_css_attr">> but it depends directly on the parameter set by the user.</p><p class="MsoNormal_mr_css_attr">> User can choose the parameter so that it suits the real allocation factor.</p><p class="MsoNormal_mr_css_attr"> </p><p class="MsoNormal_mr_css_attr">But this is not the answer on the question, is it? What is the point is</p><p class="MsoNormal_mr_css_attr">making it bigger if it can get smaller in the result? And the user can't</p><p class="MsoNormal_mr_css_attr">even understand how to select the factor he actually needs. For instance,</p><p class="MsoNormal_mr_css_attr">he sets 1.5, but he has no idea what will be the final value. How can one</p><p class="MsoNormal_mr_css_attr">tune it then? How to choose the value?</p><div class="MsoNormal_mr_css_attr"> </div><div class="MsoNormal_mr_css_attr">Answer:</div><div class="MsoNormal_mr_css_attr">This is an approximating function, so it really changes the allocation factor. <br> We can pass the real factor up and print it so that the user understands the real value </div><p class="MsoNormal_mr_css_attr"> </p><p class="MsoNormal_mr_css_attr">> diff --git a/small/small_class.h b/small/small_class.h</p><p class="MsoNormal_mr_css_attr">> new file mode 100644</p><p class="MsoNormal_mr_css_attr">> index 0000000..0677557</p><p class="MsoNormal_mr_css_attr">> --- /dev/null</p><p class="MsoNormal_mr_css_attr">> +++ b/small/small_class.h</p><p class="MsoNormal_mr_css_attr">> @@ -0,0 +1,218 @@</p><p class="MsoNormal_mr_css_attr">> +</p><p class="MsoNormal_mr_css_attr">> +/**</p><p class="MsoNormal_mr_css_attr">> + * CHAR_BIT</p><p class="MsoNormal_mr_css_attr">> + */</p><p class="MsoNormal_mr_css_attr">> +#include <limits.h></p><p class="MsoNormal_mr_css_attr">> +</p><p class="MsoNormal_mr_css_attr">> +/**</p><p class="MsoNormal_mr_css_attr">> + *</p><p class="MsoNormal_mr_css_attr"> </p><p class="MsoNormal_mr_css_attr">Unnecessary empty line.</p><div class="MsoNormal_mr_css_attr"> </div><div class="MsoNormal_mr_css_attr">Fixed: Delete unnecessary empty line.</div><div class="MsoNormal_mr_css_attr">+/**<br>+ * CHAR_BIT<br>+ */<br>+#include <limits.h><br>+<br>+/**<br>+ * small_alloc uses a collection of mempools of different sizes.</div><div class="MsoNormal_mr_css_attr"> </div><p class="MsoNormal_mr_css_attr"> </p><p class="MsoNormal_mr_css_attr">> + * small_alloc uses a collection of mempools of different sizes.</p><p class="MsoNormal_mr_css_attr">> + * If small_alloc stores all mempools in an array then it have to determine</p><p class="MsoNormal_mr_css_attr">> + * an offset in that array where the most suitable mempool is.</p><p class="MsoNormal_mr_css_attr">> + * Let's name the offset as 'size class' and the size that the corresponding</p><p class="MsoNormal_mr_css_attr">> + * mempool allocates as 'class size'.> diff --git a/test/small_class.c b/test/small_class.c</p><p class="MsoNormal_mr_css_attr">> new file mode 100644</p><p class="MsoNormal_mr_css_attr">> index 0000000..b56cfeb</p><p class="MsoNormal_mr_css_attr">> --- /dev/null</p><p class="MsoNormal_mr_css_attr">> +++ b/test/small_class.c</p><p class="MsoNormal_mr_css_attr">> @@ -0,0 +1,176 @@</p><p class="MsoNormal_mr_css_attr">> +#include "small/small_class.h"</p><p class="MsoNormal_mr_css_attr">> +#include "unit.h"</p><p class="MsoNormal_mr_css_attr">> +#include <math.h></p><p class="MsoNormal_mr_css_attr">> +</p><p class="MsoNormal_mr_css_attr">> +#define SZR(arr) sizeof(arr) / sizeof(arr[0])</p><p class="MsoNormal_mr_css_attr"> </p><p class="MsoNormal_mr_css_attr">We have lengthof() in trivia/util.h.</p><div class="MsoNormal_mr_css_attr"> </div><div class="MsoNormal_mr_css_attr">Answer:</div><div class="MsoNormal_mr_css_attr"> </div><div class="MsoNormal_mr_css_attr">We can't use lengthof() from trivia/util.h, because this file is not a part of small project.<br> Small should be built by itself without dependencies from third-party components, but<br> i change my macro SZR to lengthof as you can see in patch below:</div><div class="MsoNormal_mr_css_attr"> </div><div class="MsoNormal_mr_css_attr">+#include "small/small_class.h"<br>+#include "unit.h"<br>+#include <math.h><br>+<br>+#ifndef lengthof<br>+#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))<br>+#endif<br>+<br>+static void<br>+test_class(void)</div><p class="MsoNormal_mr_css_attr"> </p><p class="MsoNormal_mr_css_attr"> </p></div></div></div></div></div></div></div><div> </div></BODY></HTML>