aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-11-21 22:59:13 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-11-21 22:59:13 +0800
commit477df7090a0f2b7350fb61dbe30e79f02d8542f5 (patch)
tree1074e134c64f6d9b7e815fc3d212370acefc1e82 /e-util
parentbb09c40e2f9dcca5a1dbf55f5bbc572d8b7bfb9d (diff)
downloadgsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.tar
gsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.tar.gz
gsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.tar.bz2
gsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.tar.lz
gsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.tar.xz
gsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.tar.zst
gsoc2013-evolution-477df7090a0f2b7350fb61dbe30e79f02d8542f5.zip
If we dont get a big enough chunk in the first node, give up. Otherwise we
2000-11-22 Not Zed <NotZed@HelixCode.com> * e-memory.c (e_mempool_alloc): If we dont get a big enough chunk in the first node, give up. Otherwise we spend too much time searching. (e_mempool_strdup): Doh, and allocate enough for the terminating NUL at that. svn path=/trunk/; revision=6631
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/e-memory.c18
2 files changed, 17 insertions, 9 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index d370ef880e..36102ffee2 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2000-11-22 Not Zed <NotZed@HelixCode.com>
+
+ * e-memory.c (e_mempool_alloc): If we dont get a big enough chunk
+ in the first node, give up. Otherwise we spend too much time
+ searching.
+ (e_mempool_strdup): Doh, and allocate enough for the terminating
+ NUL at that.
+
2000-11-21 Not Zed <NotZed@HelixCode.com>
* e-memory.c (e_memchunk_alloc0): New function to allocate a
diff --git a/e-util/e-memory.c b/e-util/e-memory.c
index 37ec181ce9..38bfefae8a 100644
--- a/e-util/e-memory.c
+++ b/e-util/e-memory.c
@@ -397,7 +397,7 @@ MemPool *e_mempool_new(int blocksize, int threshold, EMemPoolFlags flags)
* be rounded up to the mempool's alignment restrictions
* before being used.
**/
-void *e_mempool_alloc(MemPool *pool, int size)
+void *e_mempool_alloc(MemPool *pool, register int size)
{
size = (size + pool->align) & (~(pool->align));
if (size>=pool->threshold) {
@@ -408,17 +408,17 @@ void *e_mempool_alloc(MemPool *pool, int size)
pool->threshold_blocks = n;
return &n->data[0];
} else {
- MemPoolNode *n;
+ register MemPoolNode *n;
n = pool->blocks;
- while (n) {
- if (n->free >= size) {
- n->free -= size;
- return &n->data[n->free];
- }
- n = n->next;
+ if (n && n->free >= size) {
+ n->free -= size;
+ return &n->data[n->free];
}
+ /* maybe we could do some sort of the free blocks based on size, but
+ it doubt its worth it at all */
+
n = g_malloc(sizeof(*n) - sizeof(char) + pool->blocksize);
n->next = pool->blocks;
pool->blocks = n;
@@ -431,7 +431,7 @@ char *e_mempool_strdup(EMemPool *pool, const char *str)
{
char *out;
- out = e_mempool_alloc(pool, strlen(str));
+ out = e_mempool_alloc(pool, strlen(str)+1);
strcpy(out, str);
return out;