LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-25-2009, 12:25 PM   #1
ljlinde
LQ Newbie
 
Registered: Mar 2009
Posts: 9

Rep: Reputation: 0
realloc () example of corrupt first structure


This is a continuation of the realloc() problem.
I have an example that can be compiled and run.
I would email it as an attachment to someone
who would look at it. Its too big to post.

Using gdb you can p *ptr and see the corruption of the first structure after a realloc() is called.
You can call realloc () multiple times after and all following structures and
data are correct. It only happens on the first realloc (). The value returned
by realloc () is a pointer to the first structure. The pointer value does
not change.

The work around was to calloc () two structures initally. Set a temporay pointer to stucture, to the second structure tptr = (ptr+1). This effectively bypasses the corrupted first structure. It loads compiles and does what it should do but the work around is a patch to cover up a real problem.
The code comiles and runs correctly without the patch on other
Unix machines?

What we are running is SUSE 11.with the compiler and libs that come with
the distribution.
 
Old 03-25-2009, 02:46 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by ljlinde View Post
This is a continuation of the realloc() problem.
Then why did you start a new thread?

For those who may have missed it, the starting thread is:
http://www.linuxquestions.org/questi...oblem.-713782/

Quote:
I have an example that can be compiled and run.
I would email it as an attachment to someone
who would look at it. Its too big to post.
I would look at it if you like, but only after you have answered my question from your other thread (I don't need to get a big email if my guess at the problem was already correct and you just ignored it).

Quote:
The value returned
by realloc () is a pointer to the first structure. The pointer value does
not change.
that is consistent with the error I guessed from your first post.
 
  


Reply

Tags
realloc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
realloc error on Topas kennynoah AIX 3 08-19-2008 04:33 PM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 06:46 PM
realloc, does it copy? f0rmula Programming 4 03-22-2005 02:55 PM
Realloc trouble in C KneeLess Programming 5 11-01-2004 04:16 PM
q about realloc() devoyage Programming 3 09-01-2003 12:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration