Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Reserve your abuse for your true friends. -- Larry Wall in <199712041852.KAA19364@wall.org>


devel / comp.lang.c / returning different sized ram elements by value - is it possible?

SubjectAuthor
* returning different sized ram elements by value - is it possible?fir
`- Re: returning different sized ram elements by value - is it possible?Chris M. Thomasson

1
returning different sized ram elements by value - is it possible?

<ed1a67b4-2bf2-4255-9cee-092d8c31721en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27095&group=comp.lang.c#27095

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:4e34:0:b0:63c:e9d7:2ea5 with SMTP id dm20-20020ad44e34000000b0063ce9d72ea5mr15452qvb.5.1691268762962;
Sat, 05 Aug 2023 13:52:42 -0700 (PDT)
X-Received: by 2002:a05:6870:5aaf:b0:1bf:54e9:a0b1 with SMTP id
dt47-20020a0568705aaf00b001bf54e9a0b1mr5984491oab.0.1691268762675; Sat, 05
Aug 2023 13:52:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 5 Aug 2023 13:52:42 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.212; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.212
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ed1a67b4-2bf2-4255-9cee-092d8c31721en@googlegroups.com>
Subject: returning different sized ram elements by value - is it possible?
From: profesor...@gmail.com (fir)
Injection-Date: Sat, 05 Aug 2023 20:52:42 +0000
Content-Type: text/plain; charset="UTF-8"
 by: fir - Sat, 5 Aug 2023 20:52 UTC

say i got a function and i want to return "diffarent size
ram elements" in there say

foo()
{
static char tab[100];
int n = rand()%10+1;
// return from adres &tab n bytes but by value -
}

i dont exactly remember how c returns structures by value
only remember some memcopy is involved

physically there should be possibility to use this mechanism to return n
bytes when n is chosen in runtime..though i doubt if c provides such syntax (becouse specifically in left side

x = foo()

i dont kno how to put undefined size object

Re: returning different sized ram elements by value - is it possible?

<uamevd$1soav$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=27096&group=comp.lang.c#27096

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: returning different sized ram elements by value - is it possible?
Date: Sat, 5 Aug 2023 14:29:18 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <uamevd$1soav$1@dont-email.me>
References: <ed1a67b4-2bf2-4255-9cee-092d8c31721en@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 5 Aug 2023 21:29:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ebdf46713b59c35610fdb761d80eb441";
logging-data="1991007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Mn/cvjY3zgaoDc9PpYFIvhyE1eTg0cTM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:nLStk2mkR+SzTN3IhcAzVkFg7lE=
Content-Language: en-US
In-Reply-To: <ed1a67b4-2bf2-4255-9cee-092d8c31721en@googlegroups.com>
 by: Chris M. Thomasson - Sat, 5 Aug 2023 21:29 UTC

On 8/5/2023 1:52 PM, fir wrote:
> say i got a function and i want to return "diffarent size
> ram elements" in there say
>
> foo()
> {
> static char tab[100];
> int n = rand()%10+1;
> // return from adres &tab n bytes but by value -
> }
>
> i dont exactly remember how c returns structures by value
> only remember some memcopy is involved
>
> physically there should be possibility to use this mechanism to return n
> bytes when n is chosen in runtime..though i doubt if c provides such syntax (becouse specifically in left side
>
> x = foo()
>
> i dont kno how to put undefined size object

Check this out... One of my old region allocators might be of interest
to you, examples are stack based:

https://pastebin.com/raw/f37a23918

https://groups.google.com/g/comp.lang.c/c/7oaJFWKVCTw/m/sSWYU9BUS_QJ

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor