Deutsch   English   Français   Italiano  
<v8o68a$434d$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: relearning C: why does an in-place change to a char* segfault?
Date: Sun, 4 Aug 2024 17:20:42 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <v8o68a$434d$1@dont-email.me>
References: <IoGcndcJ1Zm83zb7nZ2dnZfqnPWdnZ2d@brightview.co.uk>
 <20240801114615.906@kylheku.com> <v8gs06$2ceis$1@dont-email.me>
 <v8jlnk$31hqf$1@dont-email.me> <87bk29duba.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 04 Aug 2024 17:20:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2c5a31e759c1b6aa0f6d62d8a66085f4";
	logging-data="134285"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+isOPrdJ32L0nRm+3cd3h7RZqozZ8VsbI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:o5y++FUjfNcjkB5AyYN2Gh2shK0=
In-Reply-To: <87bk29duba.fsf@nosuchdomain.example.com>
Content-Language: en-GB, nb-NO
Bytes: 2404

On 04/08/2024 02:07, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
> [...]
>> "this is a test" is a string literal, and is typically part of the
>> program's image.  (There are some C implementations that do things
>> differently, like storing such initialisation data in a compressed
>> format.)
> [...]
> 
> What implementations do that?  Typically data that's all zeros isn't
> stored in the image, but general compression isn't something I've seen
> (not that I've paid much attention).  It would save space in the image,
> but it would require decompression at load time and wouldn't save any
> space at run time.
> 

It is a technique I have seen in embedded systems.  It is not uncommon 
for flash or other non-volatile storage to be significantly slower than 
ram, and for it to be helpful to keep the flash image as small as 
possible (this also helps for things like over-the-air updates).  The 
compression is typically fairly simple, such as run-length encoding, to 
avoid significant time, code space and temporary ram space, but it can 
help with some initialised data.