From 82fe255434134aaf2e3863b2f1285be8580bcd20 Mon Sep 17 00:00:00 2001 From: Nicholas Niro Date: Tue, 13 Jan 2009 13:47:20 -0500 Subject: [PATCH] ebuf.c : fix of a nasty bug which rendered the function Neuro_MultiAllocEBuf completely useless and dangerous. --- src/memory/ebuf.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/memory/ebuf.c b/src/memory/ebuf.c index f128ac1..8122fa4 100644 --- a/src/memory/ebuf.c +++ b/src/memory/ebuf.c @@ -223,6 +223,21 @@ Neuro_MultiAllocEBuf(EBUF *eng, u32 amount, size_t sptp, size_t sobj) total = &eng->total; mem = &eng->mem; + /* + if (amount == 1) + { + Neuro_AllocEBuf(eng, sptp, sobj); + return; + }*/ + + i = amount; + + while (i-- > 0) + { + Neuro_AllocEBuf(eng, sptp, sobj); + } + +#if temp /* we only do anything if the buffer doesn't contain anything * to avoid memory leaks. */ @@ -233,7 +248,7 @@ Neuro_MultiAllocEBuf(EBUF *eng, u32 amount, size_t sptp, size_t sobj) *mem = 0; - i = *total; + i = *total + 1; /* we need to allocate every * elements in the ** */ while (i-- > 0) @@ -241,6 +256,7 @@ Neuro_MultiAllocEBuf(EBUF *eng, u32 amount, size_t sptp, size_t sobj) (*buf)[i] = calloc(1, sobj); } } +#endif /* temp */ } void -- 2.11.4.GIT