Destroying a pipe in C

tsume

The Pervy Sage
Joined
Apr 19, 2010
Messages
21,130
Reaction score
373
Location
In the vasts of the internet
I've been try to do a bidirectional ring in C and it has not been working. I'm building my code on someone else's and the code seems problematic (and I'm suppose to use this code).
I discovered that pipes which I'm creating are not being closed. I've singled it down to the forks which are being created, which create the pipes (the code which I was given).

Is there anyway in C to destroy a pipe, the close method does not seem to be working.
 
Haven't touched this in ages, but it sounds like you have a shallow vs. deep copy problem.

So I'm imagining something like the following:

You have a variable, which you assign to the pointer / reference when creating a fork.
You are re-using this variable for each fork.

After the fork, you deallocate the variable.

Now something like this could be happening:

Create Fork 1 - A now points to Ox00
Create Fork 2 - A now points to 0x01
Destroy Fork 2 - A is now null

What happens with Fork 1? You have no way of getting that reference back.
---

Note: I'm not saying you are writing bad code: just that when all the obvious have been eliminated, I have found that in most cases in C it's something as silly as that.
 
Top
Sign up to the MyBroadband newsletter
X