Dollar, NUL, and other terminated strings, by contrast, are string length O(N).
Netstrings (1997)
21–30 of 30 posts
Re: Netstrings (1997)
#22One still functional example exists in voidlinux's init system.
There was never any need for systemd 8-/
Except leveraging RedHat/IBM's domination of the linux user space ecosystem...
Re: Netstrings (1997)
#23Another string length O(1) encoding format like Pascal strings that were len (unsigned byte) + data. Limited to 255 characters however. Dollar, NUL, and other terminated strings, by contrast, are string length O(N).
Re: Netstrings (1997)
#24if (scanf("%9lu",&len) 999999999 bytes is bad */ if (getchar() != ':') barf(); buf = malloc(len + 1); /* malloc(0) is not portable */ if (!buf) barf(); if (fread(buf,1,len,stdin) Ah, the wonders of error-handling in C. Also, I wonder what's wrong with buf = malloc(len ? len : 1);
Or even: if (len == 0) return null_buffer_singleton; /* special shared representation for 0: */
Re: Netstrings (1997)
#25Making the thing that describes the bounds of an arbitrary length thing itself arbitrary length sound like an unnecessarily risky complication to me. Especially since it only grows with the log of the thing it bounds. So, we could easily have s fixed length length field that covers all ever possible length values.
Re: Netstrings (1997)
#26Another string length O(1) encoding format like Pascal strings that were len (unsigned byte) + data. Limited to 255 characters however. Dollar, NUL, and other terminated strings, by contrast, are string length O(N).
Re: Netstrings (1997)
#27Earlier quoted context omitted.
Or even: if (len == 0) return null_buffer_singleton; /* special shared representation for 0: */
Because then the caller needs to treat it differently from non-empty buffers.
void buffer_free(void *buf)
{
if (buf != null_buffer_singleton)
free(buf);
}Re: Netstrings (1997)
#28Earlier quoted context omitted.
Because then the caller needs to treat it differently from non-empty buffers.
No, it doesn't. It calls: void buffer_free(void *buf) { if (buf != null_buffer_singleton) free(buf); }
But frankly, having a 1-byte buffer, pointer to which can serve as a sentinel value à la NULL (but dereferenceable!), and which you can pass to free() without it being deallocated is indeed rather useful.
Re: Netstrings (1997)
#29Making the thing that describes the bounds of an arbitrary length thing itself arbitrary length sound like an unnecessarily risky complication to me. Especially since it only grows with the log of the thing it bounds. So, we could easily have s fixed length length field that covers all ever possible length values.
It's mathematically impossible to describe an arbitrary length in a fixed length.
Re: Netstrings (1997)
#30Making the thing that describes the bounds of an arbitrary length thing itself arbitrary length sound like an unnecessarily risky complication to me. Especially since it only grows with the log of the thing it bounds. So, we could easily have s fixed length length field that covers all ever possible length values.
Or you could just have the standard have a "Conformance Limits" section where it says something similar to "Every implementation shall support a length field value of at least 9223372036854775807, with an unlimited number of leading zeros". In other words, values beyond that are not forbidden by the spec, but are outside of the conformance requirements. It is a quality of implementation issue whether a given implemen…