Subj : MsgBase first_msg property. To : deon From : Digital Man Date : Sun May 08 2022 19:37:51 Re: MsgBase first_msg property. By: deon to Digital Man on Mon May 09 2022 11:42 am > Re: MsgBase first_msg property. > By: Digital Man to deon on Sun May 08 2022 05:17 pm > > > > > I've added a proper caching of the last-read 'first_msg' value > > > > (caching it in the object's private data). I'll commit that now. > > > > Give it a try and let me know if it does what you were hoping for. > > > > Thanks, I was going for what you were doing but couldnt figure out how > > > first_msg would default to zero if the attribute was read and the > > > msgbase hadnt been opened yet. How are you getting that? > > > This line zeroes-out the index structure (where the first message number > > is taken): > > memset(&idx,0,sizeof(idx)); > > > If the call to smb_getfirstidx() fails, then the idx is just left as is > > (all zeroed-out). > > > Thanks, yes I saw that. But it's only called if the msgbase is opened. > > What if > > x = new MsgBase(code); > JSON.stringify(x); > > It still shows first_msg is zero (as is last_msg) - which I know is what it > should be - I couldnt follow how that was achieved for "first_msg" (I see > how it is done for the other attributes). Or was that pure luck, and it > could potentially be anything? No, not luck. In js_msgbase_constructor(), the private_t (which contains the cached first_msg value) that is allocated and associated with the object is zeroed: memset(p,0,sizeof(private_t)); Today, I would write that line: memset(p, 0, sizeof(*p)); But, same result. > It doesnt impact what I'm doing, just learning c++ code, one idea at a time > :) No problem. -- digital man (rob) Sling Blade quote #6: Karl: he should've had a chance to grow up. He would had fun some time. Norco, CA WX: 59.8øF, 71.0% humidity, 10 mph SSE wind, 0.00 inches rain/24hrs --- SBBSecho 3.15-Linux * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705) .