diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-09-11 12:33:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-09-11 15:16:36 +0300 |
commit | 3f5c54575f0cc4181b2b9fafb1cde2d1288ee506 (patch) | |
tree | 8206ff6ac0b5e972e4ea23e33d888c0934b3e944 /source/blender/makesrna/intern/makesrna.c | |
parent | 309cd047ef46fcbd21b26b2509b40c55c5dab61e (diff) |
RNA: separate internal allocation function
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 29 |
1 files changed, 18 insertions, 11 deletions
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) |