Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #74201

Re: CAlive utility casks for arbitrary code injection as needed

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: CAlive utility casks for arbitrary code injection as needed
Date 2015-10-29 20:05 +0000
Organization A noiseless patient Spider
Message-ID <87611ph24v.fsf@bsb.me.uk> (permalink)
References <334c690d-e55f-4049-87ab-d1e7150d8417@googlegroups.com>

Show all headers | View raw


"Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:

> One issue I've always had with C is the need sometimes to initialize
> pass-thru values.  I thought this might be a nice way to visualize
> the use of a cask.
>
> Consider:
>
>     01:   struct SAbc* abc;
>     02:
>     03:   for (....)
>     04:   {
>     05:       abc = NULL;
>     06:       if (some_function(&abc))
>     07:           // Do something
>     08:   }
>     09:
>     10:   SAbc* some_function(struct SAbc** abcp)
>     11:   {
>     12:       if (some_condition)
>     13:           *abcp = &some_other_abc_var;
>     14:
>     15:       return(*abcp);
>     16:   }
>
> In this case, the value of abc on line 06, it must be initialized on
> line 05 before it can be used in this context because if it is not
> initialized, it may contain a value from the prior iteration.
>
> Rather than initialize the value on line 05, that code could be changed
> into this, allowing the initialization to occur where it's needed:

Alternatively (and more topically) you could use standard C:

>     01:   struct SAbc* abc;
>     02:
>     03:   for (....)
>     04:   {
>     05:
>     06:       if (some_function(  ~|abc=NULL;|~  &abc))

  if (some_function( (abc = NULL, &abc) ))

or, if the value of abc does not need to be retained:

  if (some_function( &(struct abc *){NULL} ))

>     07:           // Do something
>     08:   }

These many not be equivalent (you've never fully defined what a "cask"
is) but the first fits the description given here, and the second works
with the scant code outline you gave.

Much better would be to post an actual code sample, a real algorithm
that's got you bothered about how to write it in C, and people here can
then help with ideas on how they would do it.  (Such threads are often
very informative.)

<snip>
-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 12:10 -0700
  Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-29 20:05 +0000
  Re: CAlive utility casks for arbitrary code injection as needed Barry Schwarz <schwarzb@dqel.com> - 2015-10-29 14:36 -0700
    Re: CAlive utility casks for arbitrary code injection as needed asetofsymbols@gmail.com - 2015-10-29 14:55 -0700
    Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 15:46 -0700
      Re: CAlive utility casks for arbitrary code injection as needed Barry Schwarz <schwarzb@dqel.com> - 2015-10-29 18:17 -0700
  Re: CAlive utility casks for arbitrary code injection as needed Bartc <bc@freeuk.com> - 2015-10-29 21:48 +0000
    Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 16:00 -0700
      Re: CAlive utility casks for arbitrary code injection as needed Ian Collins <ian-news@hotmail.com> - 2015-10-30 14:25 +1300
        Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 18:41 -0700
          Re: CAlive utility casks for arbitrary code injection as needed Philip Lantz <prl@canterey.us> - 2015-10-29 21:51 -0700
            Re: CAlive utility casks for arbitrary code injection as needed gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-30 13:07 +0000
              Re: CAlive utility casks for arbitrary code injection as needed Philip Lantz <prl@canterey.us> - 2015-11-01 11:45 -0800
          Re: CAlive utility casks for arbitrary code injection as needed Ian Collins <ian-news@hotmail.com> - 2015-10-30 20:34 +1300
            Re: CAlive utility casks for arbitrary code injection as needed Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-30 02:09 -0700
              Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-10-30 11:12 +0100
                Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 12:03 +0000
                Re: CAlive utility casks for arbitrary code injection as needed gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-30 13:16 +0000
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-10-30 14:22 +0100
                Re: CAlive utility casks for arbitrary code injection as needed Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-30 08:54 -0700
                Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 16:12 +0000
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 09:32 -0700
                Re: CAlive utility casks for arbitrary code injection as needed Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-30 09:57 -0700
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 10:16 -0700
                Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 18:33 +0000
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-10-30 22:28 +0100
                Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 23:03 +0000
                Re: CAlive utility casks for arbitrary code injection as needed Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-31 01:35 -0700
                Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-31 11:39 +0000
                Re: CAlive utility casks for arbitrary code injection as needed Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-31 12:04 -0700
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 17:56 -0700
                Re: CAlive utility casks for arbitrary code injection as needed Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-01 03:06 -0800
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 09:28 -0700
            Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 04:24 -0700
              Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-10-30 13:04 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 06:18 -0700
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-10-30 16:23 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 09:25 -0700
                Re: CAlive utility casks for arbitrary code injection as needed gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-30 16:47 +0000
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 10:13 -0700
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 10:56 -0700
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-10-31 17:04 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 09:48 -0700
                Re: CAlive utility casks for arbitrary code injection as needed gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-31 17:51 +0000
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-11-01 00:10 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-31 17:11 -0700
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-11-01 15:24 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 06:37 -0800
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-11-01 21:21 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 16:39 -0800
                Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-11-02 02:02 +0100
                Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-01 17:17 -0800
        Re: CAlive utility casks for arbitrary code injection as needed raltbos@xs4all.nl (Richard Bos) - 2015-11-02 14:24 +0000
        Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-02 07:46 -0800
          Re: CAlive utility casks for arbitrary code injection as needed gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-02 16:30 +0000
            Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-02 08:46 -0800
          Re: CAlive utility casks for arbitrary code injection as needed Les Cargill <lcargill99@comcast.com> - 2015-11-02 12:20 -0600
            Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-02 10:23 -0800
            Re: CAlive utility casks for arbitrary code injection as needed David Brown <david.brown@hesbynett.no> - 2015-11-02 20:17 +0100
      Re: CAlive utility casks for arbitrary code injection as needed Bartc <bc@freeuk.com> - 2015-10-30 01:32 +0000
        Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-29 18:59 -0700
          Re: CAlive utility casks for arbitrary code injection as needed Philip Lantz <prl@canterey.us> - 2015-10-29 21:55 -0700
            Re: CAlive utility casks for arbitrary code injection as needed gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-30 13:10 +0000
              Re: CAlive utility casks for arbitrary code injection as needed Philip Lantz <prl@canterey.us> - 2015-11-01 11:45 -0800
          Re: CAlive utility casks for arbitrary code injection as needed Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-30 10:55 +0000
  Re: CAlive utility casks for arbitrary code injection as needed Philip Lantz <prl@canterey.us> - 2015-10-29 22:00 -0700
    Re: CAlive utility casks for arbitrary code injection as needed "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-30 04:01 -0700

csiph-web