[Bf-blender-cvs] [3f5c54575f0] master: RNA: separate internal allocation function
Campbell Barton
noreply at git.blender.org
Wed Sep 11 14:24:06 CEST 2019
Commit: 3f5c54575f0cc4181b2b9fafb1cde2d1288ee506
Author: Campbell Barton
Date: Wed Sep 11 19:33:00 2019 +1000
Branches: master
https://developer.blender.org/rB3f5c54575f0cc4181b2b9fafb1cde2d1288ee506
RNA: separate internal allocation function
===================================================================
M source/blender/makesrna/intern/makesrna.c
M source/blender/makesrna/intern/rna_internal.h
===================================================================
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 5aaddc30e07..968baca3517 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -409,23 +409,30 @@ static void rna_construct_wrapper_function_name(
}
}
+void *rna_alloc_from_buffer(const char *buffer, int buffer_len)
+{
+ AllocDefRNA *alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
+ alloc->mem = MEM_mallocN(buffer_len, __func__);
+ memcpy(alloc->mem, buffer, buffer_len);
+ rna_addtail(&DefRNA.allocs, alloc);
+ return alloc->mem;
+}
+
+void *rna_calloc(int buffer_len)
+{
+ AllocDefRNA *alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
+ alloc->mem = MEM_callocN(buffer_len, __func__);
+ rna_addtail(&DefRNA.allocs, alloc);
+ return alloc->mem;
+}
+
static char *rna_alloc_function_name(const char *structname,
const char *propname,
const char *type)
{
- AllocDefRNA *alloc;
char buffer[2048];
- char *result;
-
rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type);
- result = MEM_callocN(sizeof(char) * strlen(buffer) + 1, "rna_alloc_function_name");
- strcpy(result, buffer);
-
- alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
- alloc->mem = result;
- rna_addtail(&DefRNA.allocs, alloc);
-
- return result;
+ return rna_alloc_from_buffer(buffer, strlen(buffer) + 1);
}
static StructRNA *rna_find_struct(const char *identifier)
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index fa13c56e4fa..28e2b63388a 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -543,6 +543,11 @@ PointerRNA rna_array_lookup_int(
/* Duplicated code since we can't link in blenlib */
+#ifndef RNA_RUNTIME
+void *rna_alloc_from_buffer(const char *buffer, int buffer_len);
+void *rna_calloc(int buffer_len);
+#endif
+
void rna_addtail(struct ListBase *listbase, void *vlink);
void rna_freelinkN(struct ListBase *listbase, void *vlink);
void rna_freelistN(struct ListBase *listbase);
More information about the Bf-blender-cvs
mailing list