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>2011-11-15 13:22:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-15 13:22:52 +0400
commit8623935aa838a168f64b54f4fefe472444db72fc (patch)
treeb2113b2d6b4ce0c9818d7270d7909f04fd3a8dbb /source/blender/blenkernel/intern/idprop.c
parentdf6aa48eb98da2637982e1a3d086a2e225815e13 (diff)
pass a pointer to IDP_New's IDPropertyTemplate rather then a copy.
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r--source/blender/blenkernel/intern/idprop.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 07057e4ee32..a07af5161db 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -193,7 +193,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
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 {
@@ -673,32 +673,33 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
return 1;
}
-IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name)
+/* 'val' is never NULL, dont check */
+IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
{
IDProperty *prop=NULL;
switch (type) {
case IDP_INT:
prop = MEM_callocN(sizeof(IDProperty), "IDProperty int");
- prop->data.val = val.i;
+ prop->data.val = val->i;
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:
{
/*for now, we only support float and int and double arrays*/
- if (val.array.type == IDP_FLOAT || val.array.type == IDP_INT || val.array.type == IDP_DOUBLE || val.array.type == IDP_GROUP) {
+ if (val->array.type == IDP_FLOAT || val->array.type == IDP_INT || val->array.type == IDP_DOUBLE || val->array.type == IDP_GROUP) {
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->len = prop->totallen = val.array.len;
+ 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->len = prop->totallen = val->array.len;
break;
} else {
return NULL;
@@ -706,10 +707,10 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name)
}
case IDP_STRING:
{
- const char *st = val.string.str;
+ const char *st = val->string.str;
prop = MEM_callocN(sizeof(IDProperty), "IDProperty string");
- if (val.string.subtype == IDP_STRING_SUB_BYTE) {
+ if (val->string.subtype == IDP_STRING_SUB_BYTE) {
/* note, intentionally not null terminated */
if (st == NULL) {
prop->data.pointer = MEM_callocN(DEFAULT_ALLOC_FOR_NULL_STRINGS, "id property string 1");
@@ -717,9 +718,9 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name)
prop->len = 0;
}
else {
- prop->data.pointer = MEM_mallocN(val.string.len, "id property string 2");
- prop->len = prop->totallen = val.string.len;
- memcpy(prop->data.pointer, st, val.string.len);
+ prop->data.pointer = MEM_mallocN(val->string.len, "id property string 2");
+ prop->len = prop->totallen = val->string.len;
+ memcpy(prop->data.pointer, st, val->string.len);
}
prop->subtype= IDP_STRING_SUB_BYTE;
}