CLRS icon indicating copy to clipboard operation
CLRS copied to clipboard

fix a list infinite loop bug

Open flizzywine opened this issue 6 years ago • 1 comments

imagine such code: list_t ls1 = alloc_object(1); cons(2, ls1); these code will make an infinite loop, because when alloc an object, didn't modify its next, so it naturally links with object allocated later. In this case, 2 will be next of 1, but when cons 2 and 1, 2 becomes prev of 1. to avoid this bug, fix alloc_object() function's bug by adding some statements.

flizzywine avatar Apr 02 '18 05:04 flizzywine

Is the variable new_obj same as new ?

gzc avatar Apr 02 '18 20:04 gzc