linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: deletion in singly linked list
@ 2004-11-23  9:35 Bakki Srinivas
  2004-11-23  9:55 ` Jagadeesh Bhaskar P
  0 siblings, 1 reply; 4+ messages in thread
From: Bakki Srinivas @ 2004-11-23  9:35 UTC (permalink / raw)
  To: Jagadeesh Bhaskar P; +Cc: mikael-aronsson, Justinas, Linux C Programming

[-- Attachment #1: Type: text/plain, Size: 3432 bytes --]

Until and unless u free the memory obtained by malloc,the address space is
still in the process address space.

Srinivas

-----Original Message-----
From: Jagadeesh Bhaskar P [mailto:jbhaskar@hclinsys.com]
Sent: Tuesday, November 23, 2004 3:00 PM
To: Bakki Srinivas
Cc: mikael-aronsson; Justinas; Linux C Programming
Subject: RE: deletion in singly linked list


Sorry about my last reply. There is a small, subtle problem.Say the
nodes as A, B, C itself. Now if we make B=C, still the address to which
A->next will b pointing will be the address of B itself. Now wont that
make a seg fault????

On Tue, 2004-11-23 at 14:30, Bakki Srinivas wrote:
> how is this--- 
> copy the content of the next item and place it in the current pointed
> item,check if the next item pointed by the next item is NULL if it is then
> delete the next item else move the pointer till it reaches NULL finally
> delete the last one.
> 
> Srinivas
> 
> -----Original Message-----
> From: mikael-aronsson [mailto:mikael-aronsson@telia.com]
> Sent: Tuesday, November 23, 2004 2:25 PM
> To: Justinas; Jagadeesh Bhaskar P
> Cc: Linux C Programming
> Subject: Re: deletion in singly linked list
> 
> 
> That will break the list, the previous item has to be updated so you will
> need to get the first item of the list and walk through the list until you
> find the item in front of the one you want to delete and change the "next"
> pointer in that item to point to the one in the "next" pointer in the item
> you are deleting.
> 
> Then you can delete the item you started with.
> There is no other way to do it without a double linked list.
> 
> Mikael
> 
> ----- Original Message ----- 
> From: "Justinas" <jugu3479@uosis.mif.vu.lt>
> To: "Jagadeesh Bhaskar P" <jbhaskar@hclinsys.com>
> Cc: "Linux C Programming" <linux-c-programming@vger.kernel.org>
> Sent: Tuesday, November 23, 2004 9:42 AM
> Subject: Re: deletion in singly linked list
> 
> 
> > Hello,
> >
> > i think You can. For instance n is a pointer to curent node and n->next
is
> pointer to next node. lets say we like this tmp = n, and n = n->next. After
> that free(tmp).
> >
> > On Tue, 23 Nov 2004 13:54:10 +0530
> > Jagadeesh Bhaskar P <jbhaskar@hclinsys.com> wrote:
> >
> > > I am having the address of a single node of a singly linked list. All I
> > > know about that node is that it is not the head of the list. Now say, I
> > > want to delete this node. I can infer its next node, but not its
> > > predicissor. Is there any way to delete that node, without breaking the
> > > whole linked list down!!
> > >
> > > -- 
> > > Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
> > >
> > > -
> > > To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > >
> > -
> > To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>


[-- Attachment #2: disclaimer.txt --]
[-- Type: text/plain, Size: 1091 bytes --]

-----------------------------------------------------------------------------------------------------------------------------
Disclaimer
-----------------------------------------------------------------------------------------------------------------------------

"This message(including attachment if any)is confidential and may be privileged.Before opening attachments please check them
for viruses and defects.MindTree Consulting Private Limited (MindTree)will not be responsible for any viruses or defects or
any forwarded attachments emanating either from within MindTree or outside.If you have received this message by mistake please notify the sender by return  e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited.  Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission."

-----------------------------------------------------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: deletion in singly linked list
  2004-11-23  9:35 deletion in singly linked list Bakki Srinivas
@ 2004-11-23  9:55 ` Jagadeesh Bhaskar P
  2004-11-24  3:58   ` deletion in singly linked list--pls resend replies Jagadeesh Bhaskar P
  0 siblings, 1 reply; 4+ messages in thread
From: Jagadeesh Bhaskar P @ 2004-11-23  9:55 UTC (permalink / raw)
  To: Bakki Srinivas; +Cc: mikael-aronsson, Justinas, Linux C Programming

On Tue, 2004-11-23 at 15:05, Bakki Srinivas wrote:
> Until and unless u free the memory obtained by malloc,the address space is
> still in the process address space.

Even if i do free it, where will the address A->next point to. Since it is not inside the process address space, wont that segfault??

> 
> Srinivas
> 
> -----Original Message-----
> From: Jagadeesh Bhaskar P [mailto:jbhaskar@hclinsys.com]
> Sent: Tuesday, November 23, 2004 3:00 PM
> To: Bakki Srinivas
> Cc: mikael-aronsson; Justinas; Linux C Programming
> Subject: RE: deletion in singly linked list
> 
> 
> Sorry about my last reply. There is a small, subtle problem.Say the
> nodes as A, B, C itself. Now if we make B=C, still the address to which
> A->next will b pointing will be the address of B itself. Now wont that
> make a seg fault????
> 
> On Tue, 2004-11-23 at 14:30, Bakki Srinivas wrote:
> > how is this--- 
> > copy the content of the next item and place it in the current pointed
> > item,check if the next item pointed by the next item is NULL if it is then
> > delete the next item else move the pointer till it reaches NULL finally
> > delete the last one.
> > 
> > Srinivas
> > 
> > -----Original Message-----
> > From: mikael-aronsson [mailto:mikael-aronsson@telia.com]
> > Sent: Tuesday, November 23, 2004 2:25 PM
> > To: Justinas; Jagadeesh Bhaskar P
> > Cc: Linux C Programming
> > Subject: Re: deletion in singly linked list
> > 
> > 
> > That will break the list, the previous item has to be updated so you will
> > need to get the first item of the list and walk through the list until you
> > find the item in front of the one you want to delete and change the "next"
> > pointer in that item to point to the one in the "next" pointer in the item
> > you are deleting.
> > 
> > Then you can delete the item you started with.
> > There is no other way to do it without a double linked list.
> > 
> > Mikael
> > 
> > ----- Original Message ----- 
> > From: "Justinas" <jugu3479@uosis.mif.vu.lt>
> > To: "Jagadeesh Bhaskar P" <jbhaskar@hclinsys.com>
> > Cc: "Linux C Programming" <linux-c-programming@vger.kernel.org>
> > Sent: Tuesday, November 23, 2004 9:42 AM
> > Subject: Re: deletion in singly linked list
> > 
> > 
> > > Hello,
> > >
> > > i think You can. For instance n is a pointer to curent node and n->next
> is
> > pointer to next node. lets say we like this tmp = n, and n = n->next. After
> > that free(tmp).
> > >
> > > On Tue, 23 Nov 2004 13:54:10 +0530
> > > Jagadeesh Bhaskar P <jbhaskar@hclinsys.com> wrote:
> > >
> > > > I am having the address of a single node of a singly linked list. All I
> > > > know about that node is that it is not the head of the list. Now say, I
> > > > want to delete this node. I can infer its next node, but not its
> > > > predicissor. Is there any way to delete that node, without breaking the
> > > > whole linked list down!!
> > > >
> > > > -- 
> > > > Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
> > > >
> > > > -
> > > > To unsubscribe from this list: send the line "unsubscribe
> > linux-c-programming" in
> > > > the body of a message to majordomo@vger.kernel.org
> > > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > > >
> > > -
> > > To unsubscribe from this list: send the line "unsubscribe
> > linux-c-programming" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> > -
> > To unsubscribe from this list: send the line "unsubscribe
> > linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: deletion in singly linked list--pls resend replies
  2004-11-23  9:55 ` Jagadeesh Bhaskar P
@ 2004-11-24  3:58   ` Jagadeesh Bhaskar P
  2004-11-25  7:12     ` Vadiraj
  0 siblings, 1 reply; 4+ messages in thread
From: Jagadeesh Bhaskar P @ 2004-11-24  3:58 UTC (permalink / raw)
  To: Bakki Srinivas; +Cc: mikael-aronsson, Justinas, Linux C Programming

On Tue, 2004-11-23 at 15:05, Bakki Srinivas wrote:
> Until and unless u free the memory obtained by malloc,the address space is
> still in the process address space.

Even if i do free it, where will the address A->next point to. Since it
is not inside the process address space, wont that segfault??


NB: My mail server was down yesterday :-(. If anyone of u had sent any
replies, pls do resend it.

-- 
Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: deletion in singly linked list--pls resend replies
  2004-11-24  3:58   ` deletion in singly linked list--pls resend replies Jagadeesh Bhaskar P
@ 2004-11-25  7:12     ` Vadiraj
  0 siblings, 0 replies; 4+ messages in thread
From: Vadiraj @ 2004-11-25  7:12 UTC (permalink / raw)
  To: linux-c-programming

On Wed, 24 Nov 2004 09:28:08 +0530, Jagadeesh Bhaskar P
<jbhaskar@hclinsys.com> wrote:
> On Tue, 2004-11-23 at 15:05, Bakki Srinivas wrote:
> > Until and unless u free the memory obtained by malloc,the address space is
> > still in the process address space.

 I guess the address space is still in our process address space with
in the free pool.
Further request to malloc() with <= freed size is picked up from the
free pool rather from the system...

 Please, correct me if I'm wrong

> 
> Even if i do free it, where will the address A->next point to. Since it
> is not inside the process address space, wont that segfault??
 
> NB: My mail server was down yesterday :-(. If anyone of u had sent any
> replies, pls do resend it.
> 
> --
> Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
cheers,
Vadi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-25  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-23  9:35 deletion in singly linked list Bakki Srinivas
2004-11-23  9:55 ` Jagadeesh Bhaskar P
2004-11-24  3:58   ` deletion in singly linked list--pls resend replies Jagadeesh Bhaskar P
2004-11-25  7:12     ` Vadiraj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).