flashjazzcat Posted September 15, 2014 Share Posted September 15, 2014 I dunno, could somebody who has actually written a text editor comment here, on something that could rely on using as little RAM as possible, while keeping most of it out on disk? Have a look at CoED on the BBC Micro. It uses a similar split-buffer editor to the one used in The Last Word, but in TLW I keep the entire buffer in a single 16KB bank of RAM. CoED, however, dumps the top and bottom of the file out in stacks on disk, so the edit buffer can be very small. I'm assuming you don't need word-wrap, though, in which case things get a lot easier. Having two temp files - one for each end of the file - might be worth considering anyway. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 17, 2014 Author Share Posted September 17, 2014 OOPS, edited. Slowly coding this goofy little line editor, simplifying the data structure a bit... -Thom Quote Link to comment Share on other sites More sharing options...
Albert Posted September 17, 2014 Share Posted September 17, 2014 http://i.imgur.com/B6hIfQK.png Slowly coding this goofy little line editor, simplifying the data structure a bit... -Thom Your image is not working for me, can you please check it? Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 17, 2014 Author Share Posted September 17, 2014 Fixeded... Also, I didn't commit my changes yesterday, and broke my coding streak. 45 days straight. I is a sad panda. http://github.com/tschak909 -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 18, 2014 Author Share Posted September 18, 2014 Okay, after throwing away the crap of the last two days, and replacing it with a more textbook example, the line editor backend is starting to breathe and work properly. I can insert and replace arbitrary lines of text and output it as needed: This code: https://github.com/tschak909/ataribbs/blob/master/bbslib/common/ledit.c https://github.com/tschak909/ataribbs/blob/master/bbslib/common/ledit.h Along with this test harness: #include <bbslib/common/ledit.h> #include <stdlib.h> #include <string.h> #include <stdio.h> void main() { printf("\n\n ledit test harness.\n\n"); ledit_init(); ledit_insert_at_end("Line 1 test."); ledit_insert_at_end("Line 2 is here."); ledit_insert_at_end("Line 3 is right here."); ledit_insert_at_end("Line 4 is HERE!"); ledit_insert_at_beginning("This should be on top."); ledit_insert_at_beginning("TOP OF TOP!"); ledit_insert_after_line(2,"Dropping this second from top."); ledit_debug(); ledit_done(); } Produces: Onward and upward, but at least the approach will work (The only thing being kept in memory are the line #s to the lines in the temp file, along with the linked list pointers), and take up a minimum of RAM. -Thom 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 19, 2014 Author Share Posted September 19, 2014 There is enough of the ledit backend ready, so that a UI can be constructed. That's my next task. One pattern I am trying to adhere to is that I am trying to maintain a clean separation of front-end (UI) and back-end (logic and storage), so that different UIs can be constructed. The back-end bits do not emit any UI at all, and just deal with storage, and the front-end only calls the exposed API. The one change I am going to have to make to msg, is to make it NOT take a completed character buffer to write to the message base file, but rather to allow a chunked I/O, again to keep the memory consumption as low as possible. (I am fast running out of RAM, right now in the lower 48). More as it develops. Onward and upward. -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 Boys, we've hit another major milestone: BB65 can post new messages using the line editor! Still so much to do, but I wanted to share this with everyone, the moment it started working: -Thom 4 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 Yes, Xuel. Still bugs, everywhere. -Thom 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 and now, depression sinks in... It's clear I have memory leaks in at least one place, if not everywhere... Now I have to go walking around and plug up the holes. Progress about to screech to a ($#@(R#@ halt. -Thom Quote Link to comment Share on other sites More sharing options...
TXG/MNX Posted September 20, 2014 Share Posted September 20, 2014 Take a bottle of jack daniels that will make debugging fun again :-) atleast for me it works.... Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 BBS is in maintenance mode. I have commented out the old code in bbs(), and am starting to exercise various parts of the system, in a loop, trying to exacerbate a malloc() error. -Thom Quote Link to comment Share on other sites More sharing options...
+Stephen Posted September 20, 2014 Share Posted September 20, 2014 BBS is in maintenance mode. I have commented out the old code in bbs(), and am starting to exercise various parts of the system, in a loop, trying to exacerbate a malloc() error. -Thom Ahhh - it has been SO long since I have had to do manual garbage cleanup. I have been spoiled. However, I have had to debug code using 3rd party libraries which had almost unreproducible memory leaks. It's never fun. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 so far, the big candidates, terminal_send_file() and ledit_insert_at_end() haven't caused a leak, as they have each been running for 65535 cycles, one right after the other. This leaves the msg_put_chunked() code in question... Interestingly enough, removing the call to menu() (the main UI), chopped off 12K from the BBS core, immediately...wowza. -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 As an aside, I have also got a copy of CleanUp X (CLX) on another disk, ready to load, and I've had to use it, quite a bit, while debugging the various bits of file manipulation code. Thank the universe that it works! -Thom Quote Link to comment Share on other sites More sharing options...
Albert Posted September 20, 2014 Share Posted September 20, 2014 and now, depression sinks in... It's clear I have memory leaks in at least one place, if not everywhere... Now I have to go walking around and plug up the holes. Progress about to screech to a ($#@(R#@ halt. That's alright, it's much better to take the time to find these leaks now, as they'd only get more difficult to find as the system grows in complexity. That's just a normal part of development, really. Writing new code is fun, and having to track down potentially obscure bugs is a pain in the ass. That's just the way it is. ..Al 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 20, 2014 Author Share Posted September 20, 2014 That's alright, it's much better to take the time to find these leaks now, as they'd only get more difficult to find as the system grows in complexity. That's just a normal part of development, really. Writing new code is fun, and having to track down potentially obscure bugs is a pain in the ass. That's just the way it is. ..Al Yeah, it's true, for sure... I've spent countless hours tracking down memory leaks in code bases of over 4 million+ lines... This is a lot easier in some respects.. I did find the source of the leak...one place... basically a strdup() iterating over character buffer lines, that didn't have a free() on the other end once the line had been chunked out to disk. Now, I'm tracking down some open/close port stuff... I really need to refactor things so that I can enclose critical I/O sections with a macro, and have it deal with opening/closing the terminal port, nicely. Once I do this, I'll be able to continue hammering on features. -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 21, 2014 Author Share Posted September 21, 2014 I've implemented a preliminary Chat With Sysop. It needs a bit more work on the ASCII side (I need to replicate and refactor the translation code to work in the chat mode. Why? Chat mode is special, when one side or the other starts typing, a username prompt is output, e.g. SysOp: How may I help you? TSCHAK: Hi. I'm having trouble posting messages. SysOp: I'll check it out... This works just fine with ATASCII, but due to translation issues, I need to fold in some additional code for it to display properly. Control-C at the operator console exits the chat. Once e-mail is added, I'll add an option to leave the SysOp a message when he's either out or DnD. -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 22, 2014 Author Share Posted September 22, 2014 Implemented [R]ead in [E]nter message. Edit is coming really quick, already made changes to the prompt code to allow for existing text. -Thom Quote Link to comment Share on other sites More sharing options...
idavis Posted September 23, 2014 Share Posted September 23, 2014 Thom, I think I broke it again. Cursor is stuck just sitting there. ============================================ Select File to Display: [_] Exit _ _____ ___|_|___ _____ ___ ___ _ _ | | .'| | | | -_| | | | |_|_|_|__,|_|_|_|_|_|_|___|_|_|___| [U] User List [G] Goodbye [M] Message Boards [C] Chat /w SysOp >> [M] Message Board Current message board is Atari 8-Bit Developers _ _ | |__ ___ __ _ _ _ __| |___ | '_ \/ _ \/ _` | '_/ _` (_-< |_.__/\___/\__,_|_| \__,_/__/ [N]ext Board [P]revious board [R]ead Messages [H]eader Scan [J]ump to Board [S]earch Messages [M]y Messages [Q]uick Scan [G]oodbye [X]it to main >> [R] Read Messages Read: [ENTER]Unread, [S]earch [B]egin With, [Y]ours >> [_] Last Unread Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 23, 2014 Author Share Posted September 23, 2014 Ouch, ran out of memory. wth... Ok, another leak to track down..thanks -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 24, 2014 Author Share Posted September 24, 2014 This line editor is going to eat my $#@($#@ lunch. Right now, am working on the [E]dit function, which is essentially a delete and insert operation rolled into one... checking in my work for now, and will continue working on it tomorrow. In other news, I completed my first Rubik's Cube solve, ever, yesterday. I completed by 14th, roughly an hour ago. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 25, 2014 Author Share Posted September 25, 2014 Managed to implement [E]dit while [E]ntering a message. Tip: When dealing with a linked list, you might as well just find the item in the list with the old data (the old line number), and just replace the fucking data. It's much easier than doing a delete and a subsequent insert in the same place. Atari laptop is with me in a data center at the moment, so it's offline. -Thom Quote Link to comment Share on other sites More sharing options...
Android8675 Posted September 25, 2014 Share Posted September 25, 2014 Hey Thom... messing around at the office, can't get bbsconf to write the bbs.cnf file, just locks up. Running Altirra 2.6-test9 with U1MB/SIDE2 setup. Been like that for a while, at home I have a working bbs.cnf, but can't get one made here. Enjoying reading through your code, sometimes hard to follow, but I get the gist of it. -A. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 26, 2014 Author Share Posted September 26, 2014 Yes, BBSCONF needs some love, will work on it once I get the enter message stuff working correctly. And yes, sorry, definitely a memory leak somewhere in enter message when Edit line is used. Some of you who suddenly find that the menu doesn't display, this is why. -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 26, 2014 Author Share Posted September 26, 2014 ok, I've officially hit the wall. I'm out of memory. I need to make some serious decisions now. All this insane forward progress needs to stop, while I figure out what the fuck to do next. Do I... (a) put things into overlays, and overlay them into extended memory, or (b) split things into other executables, and chain load them with an overreaching script via exit code, while holding some bits of state just below MEMHI (logged in user, etc.) What the hell do I do? I have no clue how to do (a), but I could pull off (b) probably. -Thom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.