There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

DmMacniel ,
@DmMacniel@feddit.org avatar

How would the machine know where the string would stop, since a string could contain literally any character?

But yeah… a .text section would be an alternative.

velox_vulnus OP , (edited )

I am talking about modern, or slightly dated-but-easy-to-implement alternatives to C string, like for example, the pointer+length encoding method in Rust, (which is also called record method, I think?), or the Pascal string method.

Blue_Morpho ,

You answered your own question. Strings with length are better than null terminated. It is a mistake in the original C language library and probably a hack because the pdp11 used asciz format.

SubArcticTundra ,
@SubArcticTundra@lemmy.ml avatar

Another alternative I’ve seen is strings that are not null terminated but where the allocated memory actually begins at ptr[-1] and contains the length of the string. The benefit is that you still get a char array starting at ptr[0].

velox_vulnus OP ,

But wouldn’t this be potentially unsafe? What programming language has this type of implementation, by the way?

SubArcticTundra , (edited )
@SubArcticTundra@lemmy.ml avatar

Hmm I think I saw it in a C library

Edit: Might have been this one github.com/msteinert/bstring

Edit: actually seems it’s this one. Look at what happens to ystr_header_t github.com/Amaury/Ylib/blob/master/src/ystr.c

bit ,
@bit@ohai.social avatar

@DmMacniel @velox_vulnus

Fixed length strings. You can only ever have strings of a particular length, no more, no less. No need to store the string length nor terminating characters. 🤓

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines