comparison src/if_py_both.h @ 6565:38add5a3d617 v7.4.609

updated for version 7.4.609 Problem: For complicated list and dict use the garbage collector can run out of stack space. Solution: Use a stack of dicts and lists to be marked, thus making it iterative instead of recursive. (Ben Fritz)
author Bram Moolenaar <bram@vim.org>
date Tue, 03 Feb 2015 12:55:18 +0100
parents a35752526cd0
children 4b1e3b3aa78a
comparison
equal deleted inserted replaced
6564:84171683fd66 6565:38add5a3d617
5500 Py_DECREF(run_ret); 5500 Py_DECREF(run_ret);
5501 } 5501 }
5502 PyErr_Clear(); 5502 PyErr_Clear();
5503 } 5503 }
5504 5504
5505 static void 5505 static int
5506 set_ref_in_py(const int copyID) 5506 set_ref_in_py(const int copyID)
5507 { 5507 {
5508 pylinkedlist_T *cur; 5508 pylinkedlist_T *cur;
5509 dict_T *dd; 5509 dict_T *dd;
5510 list_T *ll; 5510 list_T *ll;
5511 int abort = FALSE;
5511 5512
5512 if (lastdict != NULL) 5513 if (lastdict != NULL)
5513 for(cur = lastdict ; cur != NULL ; cur = cur->pll_prev) 5514 {
5515 for(cur = lastdict ; !abort && cur != NULL ; cur = cur->pll_prev)
5514 { 5516 {
5515 dd = ((DictionaryObject *) (cur->pll_obj))->dict; 5517 dd = ((DictionaryObject *) (cur->pll_obj))->dict;
5516 if (dd->dv_copyID != copyID) 5518 if (dd->dv_copyID != copyID)
5517 { 5519 {
5518 dd->dv_copyID = copyID; 5520 dd->dv_copyID = copyID;
5519 set_ref_in_ht(&dd->dv_hashtab, copyID); 5521 abort = abort || set_ref_in_ht(&dd->dv_hashtab, copyID, NULL);
5520 } 5522 }
5521 } 5523 }
5524 }
5522 5525
5523 if (lastlist != NULL) 5526 if (lastlist != NULL)
5524 for(cur = lastlist ; cur != NULL ; cur = cur->pll_prev) 5527 {
5528 for(cur = lastlist ; !abort && cur != NULL ; cur = cur->pll_prev)
5525 { 5529 {
5526 ll = ((ListObject *) (cur->pll_obj))->list; 5530 ll = ((ListObject *) (cur->pll_obj))->list;
5527 if (ll->lv_copyID != copyID) 5531 if (ll->lv_copyID != copyID)
5528 { 5532 {
5529 ll->lv_copyID = copyID; 5533 ll->lv_copyID = copyID;
5530 set_ref_in_list(ll, copyID); 5534 abort = abort || set_ref_in_list(ll, copyID, NULL);
5531 } 5535 }
5532 } 5536 }
5537 }
5538
5539 return abort;
5533 } 5540 }
5534 5541
5535 static int 5542 static int
5536 set_string_copy(char_u *str, typval_T *tv) 5543 set_string_copy(char_u *str, typval_T *tv)
5537 { 5544 {