我已尝试应用其他线程有关EXC_BAD_ACCESS消息的建议,但没有成功。该注释显示在def get_element(node):
# for XPATH we have to count only for nodes with same type!
length = len(list(node.previous_siblings)) + 1
if (length) > 1:
return '%s:nth-child(%s)' % (node.name, length)
else:
return node.name
def get_css_path(node):
path = [get_element(node)]
for parent in node.parents:
if parent.name == 'body':
break
path.insert(0, get_element(parent))
return ' > '.join(path)
soup = bs4.BeautifulSoup('<div></div><div><strong><i>bla</i></strong></div>')
assert get_css_path(soup.i) == 'div:nth-child(2) > strong > i'
旁边。
Node Create_Child (Node Parent_Node, int item) {
有什么见解?内存分配似乎不是问题,但我可能没有看到任何东西。
答案 0 :(得分:0)
指针,例如Child.Wolf 函数的本地,它们在Create_Child
函数之外没有任何意义,但您将这些地址分配给Child.Object_Moved
并返回它的副本。
您应该在堆上分配Child而不是
Node* Create_Child(Node Parent_Node, int item) {
Node* Child = malloc(sizeof(Node));
Child->Boat = -1*Parent_Node.Boat;
...
int* Child_Items[] = { &Child->Wolf, .. };
同样,检查函数的所有参数是否合理
在使用它们之前。例如范围内的item
?Parent_Node
有效信息?