Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » PostgreSQL Session.Open Leak??
Re: PostgreSQL Session.Open Leak?? [message #14305 is a reply to message #14283] Fri, 22 February 2008 10:09 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
indiocolifa wrote on Thu, 21 February 2008 10:28


Should I define Globalstate as a normal class (I mean, not using statics like in the Singleton pattern)?

Discovering U++ is fun!



Depends. I would either use Single directly or created a global function to return Single:

GlobalState& TheGlobalState() {
   return Single<GlobalState>();
}


but you can also stay a bit closer to "exact" singleton pattern:

class GlobalState {
   static GlobalState& getInst() { return Single<GlobalState>(); }
};


or if you insist on pointer (which IMO is stupid here, as the result can never be NULL):

class GlobalState {
   static GlobalState *getInst() { return &Single<GlobalState>(); }
};


In either case, GlobalState will be destructed at exit, avoiding memory leak.

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: updating/discarding table data on dialogs...
Next Topic: Can't fetch row...
Goto Forum:
  


Current Time: Sun Jun 09 04:37:00 CEST 2024

Total time taken to generate the page: 0.02112 seconds