Changeset View
Changeset View
Standalone View
Standalone View
source/blender/alembic/intern/alembic_capi.cc
| Context not available. | |||||
| void *abc_path_void = MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath"); | void *abc_path_void = MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath"); | ||||
| AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>(abc_path_void); | AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>(abc_path_void); | ||||
| BLI_strncpy(abc_path->path, object.getFullName().c_str(), sizeof(abc_path->path)); | abc_path->path = (char*) malloc(strlen(full_name.c_str())*sizeof(char)); | ||||
LazyDodo: this will allocate the size of a pointer, also it's preferred to use the guarded memory… | |||||
kevindietrichUnsubmitted Not Done Inline ActionsShould something like: abc_path->path = static_cast<char *>(MEM_mallocN(sizeof(char) * full_name.size()), "Alembic object path str"); Also, I prefer to be consistent with the code style, and keep using C++ style casting. kevindietrich: Should something like:
abc_path->path = static_cast<char *>(MEM_mallocN(sizeof(char) *… | |||||
| BLI_strncpy(abc_path->path, object.getFullName().c_str(), strlen(object.getFullName().c_str())); | |||||
Not Done Inline Actionssince since abc_path->path is now a pointer as well, this will copy at most 4/8 bytes and lack a zero teminator. LazyDodo: since since abc_path->path is now a pointer as well, this will copy at most 4/8 bytes and lack… | |||||
kevindietrichUnsubmitted Not Done Inline ActionsShould something like: BLI_strncpy(abc_path->path, full_name.c_str(), full_name.size()); kevindietrich: Should something like:
BLI_strncpy(abc_path->path, full_name.c_str(), full_name.size()); | |||||
| BLI_addtail(object_paths, abc_path); | BLI_addtail(object_paths, abc_path); | ||||
| free(abc_path->path); | |||||
kevindietrichUnsubmitted Not Done Inline ActionsThis will free the path directly and destroy its content, but we need it for the UI. Freeing of the strings should be done in cachefile.c before the line BLI_freelistN(&cache_file->object_paths);. kevindietrich: This will free the path directly and destroy its content, but we need it for the UI. Freeing of… | |||||
| } | } | ||||
| return parent_is_part_of_this_object; | return parent_is_part_of_this_object; | ||||
| Context not available. | |||||
| AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>( | AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>( | ||||
Not Done Inline Actionssame. LazyDodo: same. | |||||
| MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath")); | MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath")); | ||||
| BLI_strncpy(abc_path->path, full_name.c_str(), sizeof(abc_path->path)); | abc_path->path = (char*) malloc(strlen(full_name.c_str())*sizeof(char)); | ||||
| BLI_strncpy(abc_path->path, full_name.c_str(), strlen(abc_path->path)); | |||||
kevindietrichUnsubmitted Not Done Inline ActionsShould be something like: abc_path->path = static_cast<char *>(MEM_mallocN(sizeof(char) * full_name.size()), "Alembic object path str"); BLI_strncpy(abc_path->path, full_name.c_str(), full_name.size()); kevindietrich: Should be something like:
abc_path->path = static_cast<char *>(MEM_mallocN(sizeof(char) *… | |||||
| BLI_addtail(&settings.cache_file->object_paths, abc_path); | BLI_addtail(&settings.cache_file->object_paths, abc_path); | ||||
| free(abc_path->path); | |||||
kevindietrichUnsubmitted Not Done Inline ActionsHere as well, we shouldn't free directly. kevindietrich: Here as well, we shouldn't free directly. | |||||
| /* We can now assign this reader as parent for our children. */ | /* We can now assign this reader as parent for our children. */ | ||||
| if (nonclaiming_child_readers.size() + assign_as_parent.size() > 0) { | if (nonclaiming_child_readers.size() + assign_as_parent.size() > 0) { | ||||
| /* TODO: When we only support C++11, use for (a: b) instead. */ | /* TODO: When we only support C++11, use for (a: b) instead. */ | ||||
| Context not available. | |||||
this will allocate the size of a pointer, also it's preferred to use the guarded memory allocator (MEM_* functions) like the rest of the file does.