From: Mehran Rezaei <mehran@cs.unt.edu>
To: Chuck Winters <cwinters@atl.lmco.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: realloc
Date: Mon, 05 Aug 2002 18:26:54 +0000 [thread overview]
Message-ID: <3D4EC36E.43A58552@cs.unt.edu> (raw)
In-Reply-To: 20020805163543.A7759@atl.lmco.com
Chuck Winters wrote:
> Hello all,
> Anyone know why a program would freeze at realloc? I thought
> if there was a problem, realloc would just fail.
>
> Thanks,
> Chuck
> -
> 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
Hi,
The problem happens just because of specific allocator that you are using. You can
avoid it by simply malloc new area, copy the content and free previos one. Just as
follow:
#include <sys/mman.h>
ptr1=malloc(size1);
.
.
.
ptr2=realloc(ptr1,size2);
...........................
ptr1=malloc(size1);
.
.
.
ptr2=malloc(size2);
memcpy(ptr2,ptr1,size1);
free(ptr1);
Good Luck,
Mehran
next prev parent reply other threads:[~2002-08-05 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-05 20:35 realloc Chuck Winters
2002-08-05 18:26 ` Mehran Rezaei [this message]
2002-08-05 21:26 ` realloc Glynn Clements
2002-08-05 21:46 ` realloc Jason P. Winters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D4EC36E.43A58552@cs.unt.edu \
--to=mehran@cs.unt.edu \
--cc=cwinters@atl.lmco.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).