Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-12 03:47:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-12 03:47:41 +0400
commitcae11a98f98cf0fc299dbb641c6a748b83589054 (patch)
tree5700289684313664a07fd6480e9d9183f84cdf3a /source/blender/blenlib/intern/BLI_memarena.c
parentac24d98e24c0d8d1dfd005d4f332e906f1b9664c (diff)
style cleanup
Diffstat (limited to 'source/blender/blenlib/intern/BLI_memarena.c')
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index 72f312ba6e4..95a007db43e 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -30,8 +30,6 @@
* \ingroup bli
*/
-
-
#include "MEM_guardedalloc.h"
#include "BLI_memarena.h"
@@ -41,31 +39,31 @@ struct MemArena {
unsigned char *curbuf;
int bufsize, cursize;
const char *name;
-
- int use_calloc;
+
+ int use_calloc;
int align;
-
+
LinkNode *bufs;
};
MemArena *BLI_memarena_new(int bufsize, const char *name)
{
- MemArena *ma= MEM_callocN(sizeof(*ma), "memarena");
- ma->bufsize= bufsize;
+ MemArena *ma = MEM_callocN(sizeof(*ma), "memarena");
+ ma->bufsize = bufsize;
ma->align = 8;
- ma->name= name;
-
+ ma->name = name;
+
return ma;
}
void BLI_memarena_use_calloc(MemArena *ma)
{
- ma->use_calloc= 1;
+ ma->use_calloc = 1;
}
void BLI_memarena_use_malloc(MemArena *ma)
{
- ma->use_calloc= 0;
+ ma->use_calloc = 0;
}
void BLI_memarena_use_align(struct MemArena *ma, int align)
@@ -76,46 +74,47 @@ void BLI_memarena_use_align(struct MemArena *ma, int align)
void BLI_memarena_free(MemArena *ma)
{
- BLI_linklist_free(ma->bufs, (void(*)(void*)) MEM_freeN);
+ BLI_linklist_free(ma->bufs, (void(*)(void *))MEM_freeN);
MEM_freeN(ma);
}
- /* amt must be power of two */
-#define PADUP(num, amt) ((num+(amt-1))&~(amt-1))
+/* amt must be power of two */
+#define PADUP(num, amt) ((num + (amt - 1)) &~ (amt-1))
void *BLI_memarena_alloc(MemArena *ma, int size)
{
void *ptr;
- /* ensure proper alignment by rounding
- * size up to multiple of 8 */
- size= PADUP(size, ma->align);
-
- if (size>ma->cursize) {
+ /* ensure proper alignment by rounding
+ * size up to multiple of 8 */
+ size = PADUP(size, ma->align);
+
+ if (size > ma->cursize) {
unsigned char *tmp;
-
- if(size > ma->bufsize - (ma->align - 1)) {
+
+ if (size > ma->bufsize - (ma->align - 1)) {
ma->cursize = PADUP(size+1, ma->align);
}
- else ma->cursize = ma->bufsize;
+ else
+ ma->cursize = ma->bufsize;
- if(ma->use_calloc)
- ma->curbuf= MEM_callocN(ma->cursize, ma->name);
+ if (ma->use_calloc)
+ ma->curbuf = MEM_callocN(ma->cursize, ma->name);
else
- ma->curbuf= MEM_mallocN(ma->cursize, ma->name);
-
+ ma->curbuf = MEM_mallocN(ma->cursize, ma->name);
+
BLI_linklist_prepend(&ma->bufs, ma->curbuf);
/* align alloc'ed memory (needed if align > 8) */
tmp = (unsigned char*)PADUP( (intptr_t) ma->curbuf, ma->align);
ma->cursize -= (tmp - ma->curbuf);
- ma->curbuf = tmp;
+ ma->curbuf = tmp;
}
-
- ptr= ma->curbuf;
- ma->curbuf+= size;
- ma->cursize-= size;
-
+
+ ptr = ma->curbuf;
+ ma->curbuf += size;
+ ma->cursize -= size;
+
return ptr;
}