Boost logo

Boost :

Subject: Re: [boost] C++ Boost library - passing Shared pointer to a function
From: abhishek goswami (zeal_goswami_at_[hidden])
Date: 2012-09-08 09:21:04


I am looking for a project which is converting c malloc/realloc to shared_ptr. During my Analysis, I found the issue Can anyone provide me some input how to fix below issue typedef boost::shared_ptr<Employee_t> srdpointer; srdpointer ptr((Employee_t*)malloc(sizeof(Employee_t)),std::ptr_fun(free)); I need to pass the shared pointer which will allocate memory Pointed by the ptr. Something like this. void allocateBlocks(int **ptr, int *cnt)     {         *ptr = (int*)malloc(sizeof(int) * 10);         *cnt = 10;         /*do something*/     }     int main()     {         int *p = NULL;         int count = 0;         allocateBlocks(&p, &count);         /*do something*/         free(p);     } How can I achieve the similar functionality using shared ptr as shown in above code


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk