8,214 karma · joined Nov 7, 2019 (7y ago) · 5,323 submissions
comment 1y ago · link · parent
I explained how returning the address of the string buffer instead of the address of the struct would give you a C compatible string that you could pass to other C library functions. If those functions are "readonly" wrt the string, everything is copasetic.
if those string functions update/write the c-string (which is in the buffer) the strlen in the header will now be wrong. That has nothing to do with my suggestion, and it's already "broken" in that way you point out. My "string free bytes field" suggestion will also be broken by an operation like that, so my suggestion does not make this data structure worse than it already is wrt compatibility with C library functions.
However that strlen and free bytes problem can be managed (no worse than C standard strings themselves) and strlen and/or free bytes are useful features that make some other things easier so overall it's a win.
comment 1y ago · link · parent
+--------+-------------------------------+-----------+
| Header | Binary safe C alike string... | Null term |
+--------+-------------------------------+-----------+
|
`-> Pointer returned to the user.
his trick is to create a struct with fields in the header for extra information about the string, and then a string buffer also in the struct. but on instantiation, instead of returning the address of the struct/header, he returns the address of the string, so it could be passed to strlen and return the right answer, or open and open the right file, all compatible-like.but if you call "methods" on the package, they know that there is a header with struct fields below the string buffer and it can obtain those, and update them if need be.
He doesn't document that in more detail in the initial part of the spec/readme, but an obvious thing to add in the header would be a strlen, so you'd know where to append without counting through the string. But without doing something like that, there is no reason to have a header. Normal string functions can "handle" these strings, but they can't update the header information. I'm just extending that concept to the byte at the end also.
this type of thing falls into what the soulless ginger freaks call UB and want to eliminate.
(soulless ginger freaks? a combination of "rust colored" and https://www.youtube.com/watch?v=EY39fkmqKBM )
comment 1y ago · link · parent
but i did see a place to shave a byte in the sds data struct. The null terminator is a wasted field, that byte (or int) should be used to store the amount of free space left in the buffer (as a proxy for strlen). When there is no space left in the buffer, the free space value will be.... a very convenient 0 heheh
hey, OP said he wants to be a better C programmer!
comment 1y ago · link · parent
I'd be curious what the numbers are for the "good" that this therapy does; is there any way that this therapy is still "worth it" at any scale? but I know little about this area so that's a fairly naive question.
comment 1y ago · link · parent
"Nearly 3,500 residents across 16 rural villages have been unable to drink tap water since July 10"
and "At this stage, statistically, there are no adverse health indicators demonstrating a health consequence for the populations of these villages."
comment 1y ago · link · parent
it's not unfair since you took the risk of potentially losing your original investment; you also put in the time to learn about baseball cards, while other people were interested in antiques and studied and bought those, also with a risk that what they bought would decrease in value.
Can I interest you in some Beanie Babies?
comment 1y ago · link · parent
it's a small point but, "elites" usually refers to those with good educational credentials who hold down white collar jobs at universities, newsmedia, law and finance firms, political campaigns, non-profits, etc., jobs they got because their parents know how to help them network and who can afford to pay their rent in major cities while they "pay their dues" as interns in these same organizations. Yes, they do have higher than average incomes, but I heard a great word for them (from a left-leaning source fwiw) who called them "the 19%". They are not the 1%, but they make up the rest of the 20% and they work for the 1%, and though they often have left leaning political ideals, it's human nature to want to defend what you have and feel you earned it, and also to pass it along and take care of your own children's futures. According to this guy, they control 2x the wealth that the 1% controls and flex a lot of political muscle.
Billionaires, oligarchs, and other members of the uber rich are generally referred to as just those things. The people behind this study I would guess are in the 19%, and by labelling the billionaires and oligarchs as elites, unconsciously they shed the shame of being elites themselves (Dartmouth? pure ivy league).
comment 1y ago · link · parent
At the same time, when major compiler vendors couldn't even get their Ada compilers out the door in project overruns measured in years, Mitch Kapor's 1-2-3 was written and took over the spreadsheet market (dethroning the incumbent Visicalc) and it was written in assembler, not even C, and barely had memory to spare on user machines (memory? there was barely address space left to spare). The tradeoffs were authentic, and there was zero enthusiasm for Ada among programmers or entrepreneurs looking to get products launched. The mainframe world could have been different but the personal computer software market was exploding in a way larger systems never did.
(oh and let me add, all the undefined behaviors back then were very clearly defined (perhaps over a small field of options) and extremely useful, and should have been left that way; shoot out a compiler warning or error if they get your panties in a bunch)
comment 1y ago · link · parent
it's not unprecedented, when companies' businesses contract, shrinking is exactly the right thing to do, not to mention that it's forced on them anyway.
comment 1y ago · link · parent
comment 1y ago · link · parent
comment 1y ago · link · parent
>Nit: You probably mean Cue, as in "That's your time to go on stage" not Queue as in "that's your place in line"
bone to pick: you missed your opportunity to cool-ly say "not queue as in hair worn in a long plait descending down the back"
comment 1y ago · link · parent
https://www.wbur.org/news/2019/03/07/buckminster-fuller-geod...
1166.
Ask HN: Where(s) is /usr/shar/dict/words maintained?
2 points · by fsckboy · 1y ago · 1 comment