@@ -188,7 +188,8 @@ dict_free_items(int copyID)
188188/*
189189 * Allocate a Dictionary item.
190190 * The "key" is copied to the new item.
191- * Note that the value of the item "di_tv" still needs to be initialized!
191+ * Note that the type and value of the item "di_tv" still needs to be
192+ * initialized!
192193 * Returns NULL when out of memory.
193194 */
194195 dictitem_T *
@@ -201,6 +202,7 @@ dictitem_alloc(char_u *key)
201202 {
202203 STRCPY (di -> di_key , key );
203204 di -> di_flags = DI_FLAGS_ALLOC ;
205+ di -> di_tv .v_lock = 0 ;
204206 }
205207 return di ;
206208}
@@ -338,7 +340,6 @@ dict_add_number(dict_T *d, char *key, varnumber_T nr)
338340 item = dictitem_alloc ((char_u * )key );
339341 if (item == NULL )
340342 return FAIL ;
341- item -> di_tv .v_lock = 0 ;
342343 item -> di_tv .v_type = VAR_NUMBER ;
343344 item -> di_tv .vval .v_number = nr ;
344345 if (dict_add (d , item ) == FAIL )
@@ -361,7 +362,6 @@ dict_add_string(dict_T *d, char *key, char_u *str)
361362 item = dictitem_alloc ((char_u * )key );
362363 if (item == NULL )
363364 return FAIL ;
364- item -> di_tv .v_lock = 0 ;
365365 item -> di_tv .v_type = VAR_STRING ;
366366 item -> di_tv .vval .v_string = str != NULL ? vim_strsave (str ) : NULL ;
367367 if (dict_add (d , item ) == FAIL )
@@ -384,7 +384,6 @@ dict_add_list(dict_T *d, char *key, list_T *list)
384384 item = dictitem_alloc ((char_u * )key );
385385 if (item == NULL )
386386 return FAIL ;
387- item -> di_tv .v_lock = 0 ;
388387 item -> di_tv .v_type = VAR_LIST ;
389388 item -> di_tv .vval .v_list = list ;
390389 ++ list -> lv_refcount ;
@@ -408,7 +407,6 @@ dict_add_dict(dict_T *d, char *key, dict_T *dict)
408407 item = dictitem_alloc ((char_u * )key );
409408 if (item == NULL )
410409 return FAIL ;
411- item -> di_tv .v_lock = 0 ;
412410 item -> di_tv .v_type = VAR_DICT ;
413411 item -> di_tv .vval .v_dict = dict ;
414412 ++ dict -> dv_refcount ;
0 commit comments