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-05-06 21:22:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-06 21:22:54 +0400
commitffed654ff2a1349b735026aafde6f8937a4a3f15 (patch)
treeaee57d96cc5f5a3e425bf0f17477101ab899a87c /source/blender/blenkernel/intern/idprop.c
parent1118b3fe3f6a9597403e8eb61f33e7a877098145 (diff)
style cleanup: blenkernel
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r--source/blender/blenkernel/intern/idprop.c134
1 files changed, 67 insertions, 67 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index dfe73ae20db..e3735cfd374 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -47,16 +47,16 @@ static char idp_size_table[] = {
1, /*strings*/
sizeof(int),
sizeof(float),
- sizeof(float)*3, /*Vector type, deprecated*/
- sizeof(float)*16, /*Matrix type, deprecated*/
+ sizeof(float) * 3, /*Vector type, deprecated*/
+ sizeof(float) * 16, /*Matrix type, deprecated*/
0, /*arrays don't have a fixed size*/
sizeof(ListBase), /*Group type*/
- sizeof(void*),
+ sizeof(void *),
sizeof(double)
};
/* ------------Property Array Type ----------- */
-#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i))
+#define GETPROP(prop, i) (((IDProperty *)(prop)->data.pointer) + (i))
/* --------- property array type -------------*/
@@ -78,10 +78,10 @@ IDProperty *IDP_CopyIDPArray(IDProperty *array)
IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp;
int i;
- *narray= *array;
+ *narray = *array;
narray->data.pointer = MEM_dupallocN(array->data.pointer);
- for (i=0; i<narray->len; i++) {
+ for (i = 0; i < narray->len; i++) {
/* ok, the copy functions always allocate a new structure,
* which doesn't work here. instead, simply copy the
* contents of the new structure into the array cell,
@@ -100,7 +100,7 @@ void IDP_FreeIDPArray(IDProperty *prop)
{
int i;
- for (i=0; i<prop->len; i++)
+ for (i = 0; i < prop->len; i++)
IDP_FreeProperty(GETPROP(prop, i));
if (prop->data.pointer)
@@ -124,22 +124,22 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item)
{
- IDP_ResizeIDPArray(prop, prop->len+1);
- IDP_SetIndexArray(prop, prop->len-1, item);
+ IDP_ResizeIDPArray(prop, prop->len + 1);
+ IDP_SetIndexArray(prop, prop->len - 1, item);
return item;
}
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
{
void *newarr;
- int newsize=newlen;
+ int newsize = newlen;
/*first check if the array buffer size has room*/
/*if newlen is 200 chars less then totallen, reallocate anyway*/
if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
int i;
- for (i=newlen; i<prop->len; i++)
+ for (i = newlen; i < prop->len; i++)
IDP_FreeProperty(GETPROP(prop, i));
prop->len = newlen;
@@ -156,18 +156,18 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
*/
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
- newarr = MEM_callocN(sizeof(IDProperty)*newsize, "idproperty array resized");
+ newarr = MEM_callocN(sizeof(IDProperty) * newsize, "idproperty array resized");
if (newlen >= prop->len) {
/* newlen is bigger*/
- memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty));
+ memcpy(newarr, prop->data.pointer, prop->len * sizeof(IDProperty));
}
else {
int i;
/* newlen is smaller*/
- for (i=newlen; i<prop->len; i++) {
+ for (i = newlen; i < prop->len; i++) {
IDP_FreeProperty(GETPROP(prop, i));
}
- memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty));
+ memcpy(newarr, prop->data.pointer, newlen * sizeof(IDProperty));
}
if (prop->data.pointer)
@@ -185,21 +185,21 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
if (newlen >= prop->len) {
/* bigger */
- IDProperty **array= newarr;
+ IDProperty **array = newarr;
IDPropertyTemplate val;
int a;
- for (a=prop->len; a<newlen; a++) {
+ for (a = prop->len; a < newlen; a++) {
val.i = 0; /* silence MSVC warning about uninitialized var when debugging */
- array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
+ array[a] = IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
}
}
else {
/* smaller */
- IDProperty **array= prop->data.pointer;
+ IDProperty **array = prop->data.pointer;
int a;
- for (a=newlen; a<prop->len; a++) {
+ for (a = newlen; a < prop->len; a++) {
IDP_FreeProperty(array[a]);
MEM_freeN(array[a]);
}
@@ -210,7 +210,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
void IDP_ResizeArray(IDProperty *prop, int newlen)
{
void *newarr;
- int newsize=newlen;
+ int newsize = newlen;
/*first check if the array buffer size has room*/
/*if newlen is 200 chars less then totallen, reallocate anyway*/
@@ -230,16 +230,16 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
*/
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
- newarr = MEM_callocN(idp_size_table[(int)prop->subtype]*newsize, "idproperty array resized");
+ newarr = MEM_callocN(idp_size_table[(int)prop->subtype] * newsize, "idproperty array resized");
if (newlen >= prop->len) {
/* newlen is bigger*/
- memcpy(newarr, prop->data.pointer, prop->len*idp_size_table[(int)prop->subtype]);
+ memcpy(newarr, prop->data.pointer, prop->len * idp_size_table[(int)prop->subtype]);
idp_resize_group_array(prop, newlen, newarr);
}
else {
/* newlen is smaller*/
idp_resize_group_array(prop, newlen, newarr);
- memcpy(newarr, prop->data.pointer, newlen*idp_size_table[(int)prop->subtype]);
+ memcpy(newarr, prop->data.pointer, newlen * idp_size_table[(int)prop->subtype]);
}
MEM_freeN(prop->data.pointer);
@@ -257,8 +257,8 @@ void IDP_FreeArray(IDProperty *prop)
}
- static IDProperty *idp_generic_copy(IDProperty *prop)
- {
+static IDProperty *idp_generic_copy(IDProperty *prop)
+{
IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
@@ -268,7 +268,7 @@ void IDP_FreeArray(IDProperty *prop)
newp->data.val2 = prop->data.val2;
return newp;
- }
+}
static IDProperty *IDP_CopyArray(IDProperty *prop)
{
@@ -278,11 +278,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
if (prop->type == IDP_GROUP) {
- IDProperty **array= newp->data.pointer;
+ IDProperty **array = newp->data.pointer;
int a;
- for (a=0; a<prop->len; a++)
- array[a]= IDP_CopyProperty(array[a]);
+ for (a = 0; a < prop->len; a++)
+ array[a] = IDP_CopyProperty(array[a]);
}
}
newp->len = prop->len;
@@ -294,12 +294,12 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
/*taken from readfile.c*/
#define SWITCH_LONGINT(a) { \
- char s_i, *p_i; \
- p_i= (char *)&(a); \
- s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
- s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
- s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
- s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
+ char s_i, *p_i; \
+ p_i = (char *)& (a); \
+ s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \
+ s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \
+ s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \
+ s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; }
@@ -350,7 +350,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen)
int stlen = strlen(st);
if (maxlen > 0 && maxlen < stlen)
- stlen= maxlen;
+ stlen = maxlen;
if (prop->subtype == IDP_STRING_SUB_BYTE) {
IDP_ResizeArray(prop, stlen);
@@ -396,14 +396,14 @@ void IDP_FreeString(IDProperty *prop)
void IDP_LinkID(IDProperty *prop, ID *id)
{
- if (prop->data.pointer) ((ID*)prop->data.pointer)->us--;
+ if (prop->data.pointer) ((ID *)prop->data.pointer)->us--;
prop->data.pointer = id;
id_us_plus(id);
}
void IDP_UnlinkID(IDProperty *prop)
{
- ((ID*)prop->data.pointer)->us--;
+ ((ID *)prop->data.pointer)->us--;
}
/*-------- Group Functions -------*/
@@ -414,7 +414,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
IDProperty *newp = idp_generic_copy(prop), *link;
newp->len = prop->len;
- for (link=prop->data.group.first; link; link=link->next) {
+ for (link = prop->data.group.first; link; link = link->next) {
BLI_addtail(&newp->data.group, IDP_CopyProperty(link));
}
@@ -426,22 +426,22 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
{
IDProperty *other, *prop;
- for (prop=src->data.group.first; prop; prop=prop->next) {
- other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
- if (other && prop->type==other->type) {
+ for (prop = src->data.group.first; prop; prop = prop->next) {
+ other = BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
+ if (other && prop->type == other->type) {
switch (prop->type) {
case IDP_INT:
case IDP_FLOAT:
case IDP_DOUBLE:
- other->data= prop->data;
+ other->data = prop->data;
break;
case IDP_GROUP:
IDP_SyncGroupValues(other, prop);
break;
default:
{
- IDProperty *tmp= other;
- IDProperty *copy= IDP_CopyProperty(prop);
+ IDProperty *tmp = other;
+ IDProperty *copy = IDP_CopyProperty(prop);
BLI_insertlinkafter(&dest->data.group, other, copy);
BLI_remlink(&dest->data.group, tmp);
@@ -460,8 +460,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
{
IDProperty *loop, *prop;
- for (prop=src->data.group.first; prop; prop=prop->next) {
- for (loop=dest->data.group.first; loop; loop=loop->next) {
+ for (prop = src->data.group.first; prop; prop = prop->next) {
+ for (loop = dest->data.group.first; loop; loop = loop->next) {
if (strcmp(loop->name, prop->name) == 0) {
IDProperty *copy = IDP_CopyProperty(prop);
@@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{
IDProperty *loop;
- if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) {
+ if ((loop = IDP_GetPropertyFromGroup(group, prop->name))) {
BLI_insertlink(&group->data.group, loop, prop);
BLI_remlink(&group->data.group, loop);
@@ -539,7 +539,7 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type)
{
- IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name);
+ IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name);
return (idprop && idprop->type == type) ? idprop : NULL;
}
@@ -553,20 +553,20 @@ void *IDP_GetGroupIterator(IDProperty *prop)
IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter");
iter->next = prop->data.group.first;
iter->parent = prop;
- return (void*) iter;
+ return (void *) iter;
}
IDProperty *IDP_GroupIterNext(void *vself)
{
- IDPIter *self = (IDPIter*) vself;
- Link *next = (Link*) self->next;
+ IDPIter *self = (IDPIter *) vself;
+ Link *next = (Link *) self->next;
if (self->next == NULL) {
MEM_freeN(self);
return NULL;
}
self->next = next->next;
- return (void*) next;
+ return (void *) next;
}
void IDP_FreeIterBeforeEnd(void *vself)
@@ -581,7 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
static void IDP_FreeGroup(IDProperty *prop)
{
IDProperty *loop;
- for (loop=prop->data.group.first; loop; loop=loop->next) {
+ for (loop = prop->data.group.first; loop; loop = loop->next) {
IDP_FreeProperty(loop);
}
BLI_freelistN(&prop->data.group);
@@ -635,7 +635,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0);
else if (prop1->type == IDP_ARRAY) {
if (prop1->len == prop2->len && prop1->subtype == prop2->subtype)
- return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype]*prop1->len);
+ return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len);
else
return 0;
}
@@ -645,8 +645,8 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
return 0;
- for (link1=prop1->data.group.first; link1; link1=link1->next) {
- link2= IDP_GetPropertyFromGroup(prop2, link1->name);
+ for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
+ link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
if (!IDP_EqualsProperties(link1, link2))
return 0;
@@ -655,14 +655,14 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
return 1;
}
else if (prop1->type == IDP_IDPARRAY) {
- IDProperty *array1= IDP_IDPArray(prop1);
- IDProperty *array2= IDP_IDPArray(prop2);
+ IDProperty *array1 = IDP_IDPArray(prop1);
+ IDProperty *array2 = IDP_IDPArray(prop2);
int i;
if (prop1->len != prop2->len)
return 0;
- for (i=0; i<prop1->len; i++)
+ for (i = 0; i < prop1->len; i++)
if (!IDP_EqualsProperties(&array1[i], &array2[i]))
return 0;
}
@@ -673,7 +673,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
/* 'val' is never NULL, don't check */
IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
{
- IDProperty *prop=NULL;
+ IDProperty *prop = NULL;
switch (type) {
case IDP_INT:
@@ -682,11 +682,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
break;
case IDP_FLOAT:
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
- *(float*)&prop->data.val = val->f;
+ *(float *)&prop->data.val = val->f;
break;
case IDP_DOUBLE:
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
- *(double*)&prop->data.val = val->d;
+ *(double *)&prop->data.val = val->d;
break;
case IDP_ARRAY:
{
@@ -699,7 +699,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop = MEM_callocN(sizeof(IDProperty), "IDProperty array");
prop->subtype = val->array.type;
if (val->array.len)
- prop->data.pointer = MEM_callocN(idp_size_table[val->array.type]*val->array.len, "id property array");
+ prop->data.pointer = MEM_callocN(idp_size_table[val->array.type] * val->array.len, "id property array");
prop->len = prop->totallen = val->array.len;
break;
}
@@ -724,7 +724,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop->len = prop->totallen = val->string.len;
memcpy(prop->data.pointer, st, val->string.len);
}
- prop->subtype= IDP_STRING_SUB_BYTE;
+ prop->subtype = IDP_STRING_SUB_BYTE;
}
else {
if (st == NULL) {
@@ -738,7 +738,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop->len = prop->totallen = stlen;
memcpy(prop->data.pointer, st, stlen);
}
- prop->subtype= IDP_STRING_SUB_UTF8;
+ prop->subtype = IDP_STRING_SUB_UTF8;
}
break;
}