Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #19327
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Subject | Re: Bug in beginner's linked-list code |
| Newsgroups | comp.lang.forth |
| Message-ID | <09561504028434@frunobulax.edu> (permalink) |
| Date | 2013-01-31 20:47 +0200 |
| References | <961f6894-e6a6-4bed-88be-3c7531fe7c5e@googlegroups.com> |
| Organization | Wanadoo |
laheadle@gmail.com writes Re: Bug in beginner's linked-list code > I am building a simple linked-list structure using FreeForth, > but my code has a bug. > When I create a node, then attempt to create another node and > insert the second node after the first node, I get a segmentation > fault. Can anyone help? > Here is the code that crashes: > 4 newNode 5 insertAfter ; You didn't type the ";" I hope? > ( start@ val -- ) > : insertAfter > newNode swap \ newNode@ start@ > dup nextNode \ -- newNode@ start@ cnext@ > 0- 0= IF \ last one > drop [..] > ; Try DUP instead of 0- . Several pieces seem to be missing from your algorithm. -marcel
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bug in beginner's linked-list code laheadle@gmail.com - 2013-01-31 08:52 -0800
Re: Bug in beginner's linked-list code mhx@iae.nl (Marcel Hendrix) - 2013-01-31 20:47 +0200
Re: Bug in beginner's linked-list code laheadle@gmail.com - 2013-02-01 07:57 -0800
Re: Bug in beginner's linked-list code "Elizabeth D. Rather" <erather@forth.com> - 2013-02-01 09:21 -1000
Re: Bug in beginner's linked-list code Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-02-04 17:04 -0800
Re: Bug in beginner's linked-list code november.nihal@gmail.com - 2013-02-05 16:15 -0800
csiph-web