Click here to Skip to main content
13,556,208 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want to modular & parametrise coding in which all variables,file pointers,device handles are initialise in one function & release in another function,I don't get idea about it!!How does that?Please suggest me solution for better performance of code & solution.
Thanks in Advance!
Posted 21-Jan-13 2:52am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

In C++ you may use RAII[^]. Do initialization in the constructor, do some cleanup in the destructor. Take special care of exceptions in the destructor.

In C you must tell the client of your code to follow the protocol: call first some invented Init(...) function, then at the end some invented Release(...) function. Both functions are part of your library and do what you require in your question.
Sergey Alexandrovich Kryukov 21-Jan-13 11:22am
RAII is a very beneficial thing, my 5. The question is too vague though...
Andreas Gieriet 21-Jan-13 11:35am
Thank you for your 5!
I agree that this question is rather fuzzy. I read that the OP is in need of RAII. No clue, though, what it has to do with C...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02-2016 | 2.8.180515.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100