home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,740 of 33,346   
   Fredrik Staxeng to daniel.kruegler@googlemail.com   
   Re: C API needs array of C strings, what   
   14 Dec 11 06:20:59   
   
   From: fstx+u@update.uu.se   
      
   Daniel Krügler  writes:   
      
   >Am 13.12.2011 22:41, schrieb Fredrik Staxeng:   
   >> WWSAPI represents an array of strings as (WCHAR **array, int count).   
   >   
   >For non-Windows users: WCHAR is a typedef for wchar_t   
      
   Thank you all for your replies. I am sorry that the information was   
   incomplete. The function widen does allocate memory for the returned   
   string.   
      
   I have wrapped the array in an object in RAII fashion. One thing that   
   bothers me is a subtle interaction between the constructor and   
   destructor to ensure the right delete calls when an exception is   
   thrown. My first draft would free garbage pointers.   
      
   I know std::vector provides the memory layout guarantee needed in this   
   case. But if I put raw pointers into the vector, I still need to   
   free them explicitly. I could wrap them into a moveable object   
   that owns the string, but isn't this what std::unique_ptr is?   
      
   I also got a pointer to boost::ptr_vector. If I can convince it to use   
   delete [] on its pointers..   
      
   --   
   Fredrik Stax\"ang | rot13: sfgk@hcqngr.hh.fr   
   This is all you need to know about vi: ESC : q ! RET   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca