|
RE: peekCString stack overflow: msg#00009lang.haskell.glasgow.bugs
> Off the top of my head: > > 1) Compute length of C string. > (As usual, need to use seq on the '+1' argument.) > 2) Scan from right to left, constructing the list. Ah yes, that's the trick I was forgetting about, thanks. > Or, since making two passes seems ugly, construct the list in > reverse and then > return the reversed list: > > peekCString ptr = peekCString' ptr [] > where > peekCString' ptr r = do > c <- peek ptr > if c == '\0' > then return (reverse r) > else peekCString' (ptr+1) (c:r) > > I have a nasty feeling that reverse doesn't work in constant > stack space though so this probably doesn't work. That's right: using reverse doesn't help. Cheers, Simon
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: peekCString stack overflow, Ross Paterson |
|---|---|
| Next by Date: | Re: peekCString stack overflow, George Russell |
| Previous by Thread: | Re: peekCString stack overflow, George Russell |
| Next by Thread: | [ ghc-Bugs-818425 ] Bad sparc Int64 code via NCG with -O, SourceForge.net |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |