By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

realloc() without using malloc() or calloc()

P: 56
I have a function,


int dmgDocExplodeInception
(
sENTITY* Entity,
sDOC_SOURCE* DocSource,
sUINT Mode
)
{
//some lines of code
void*& blob_ptr = DocSource->DocData->BinaryText->data;
//some line of code

if (blob_ptr != 0)
{
//some lines of code
blob_ptr = realloc(blob_ptr, blob_size + additional_space + 1);
//some lines of code
}
//some lines of code
}

My doubt is. for blob_ptr, there is no malloc() or calloc().
Is it correct to use realloc() for blob_ptr then?
Also blob_ptr has not been deleted anywhere.
Please let me know. Thanks.
Aug 10 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
My doubt is. for blob_ptr, there is no malloc() or calloc().
Is it correct to use realloc() for blob_ptr then?
If that variable equals NULL, realloc will function identical to malloc(), so yes you
could use that.

kind regards,

Jos
Aug 10 '07 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Also blob_ptr has not been deleted anywhere.
That's not good. You should call free() on it.
Aug 10 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.