Re: IS this a proper way of freeing memory with free()



Richard Heathfield wrote:
Ian Collins said:

Richard Heathfield wrote:

Ian Collins said:

Richard Heathfield wrote:

Yevgen Muntyan said:

It's easy to write lot of C code which is valid C++. You have to
apply casts to return value of malloc though.

It's *pointless* to write lots of C code which is valid C++. [...]

It's not pointless if you are using C++ for hardware simulations to
test your C drivers.

If you're using C++ for the hardware simulations, you're using C++,
not C.

The driver code is C.

Fine, in which case it isn't C++, so you don't need the cast on malloc.

I'm not sure if you are being deliberately obtuse.

My point is there is sometimes value in having C code which is valid
C++. The driver code in question is compiled as C for the embedded
target, but compiled with the host C++ compiler for testing in a
hardware simulator.

So the code in question is written in the subset of C that is valid C++.

--
Ian Collins.
.



Relevant Pages

  • Re: [SLE] Rhetorical question
    ... > Linux licensing requirements are not given quarter; ... > confidential Windows specs or code, in breach of a Windows licence, in ... copyright and /or patented hardware specifications or driver code is ...
    (SuSE)
  • Re: [PATCH 2/4] virtual block device driver (ramzswap)
    ... There's strspn so maybe you could introduce a memspn equivalent. ... this simple function should stay within this driver only. ... helpers in driver code where they don't belong (and won't be ...
    (Linux-Kernel)
  • [RFC][PATCH] netconsole: avoid deadlock on printk from driver code
    ... Subject: netconsole: avoid deadlock on printk from driver code ... I encountered a hard-to-debug deadlock when I pulled out the plug of my ... RealTek 8139 which was also running netconsole: The driver wants to print ...
    (Linux-Kernel)
  • Re: Using malloc() with driver code ?!
    ... I am using memcpy inside my driver. ... difference between malloc() and memcpy? ... > Walter Oney, Consulting and Training ...
    (microsoft.public.development.device.drivers)
  • Re: [RFC][PATCH] netconsole: avoid deadlock on printk from driver code
    ... driver code. ... determine whether a deadlock can occur if we try to transmit another ... Note that this may lead to lost messages if the driver is active on ... another CPU while we try to use the same device for netconsole. ...
    (Linux-Kernel)