This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
DLL function with string result?
- To: cygwin at cygwin dot com
- Subject: DLL function with string result?
- From: Christian Lescher <christian at lescher dot de>
- Date: Thu, 19 Apr 2001 21:57:09 +0200
- CC: christian dot lescher at icn dot siemens dot de
For writing a DLL function that returns a string result, I need a C
function that takes a pointer to a given string, creates a copy of it
and returns a pointer to the copied string. (The string may be > 64 KB
and should be freed again by the calling program.)
This is probably a rather simple task, but I didn't succeed yet. I tried
something like:
#include <stdlib.h>
#include <string.h>
char*
mallocAndStrCpy (const char* srcStr) {
return strcpy((char*) malloc(strlen (srcStr)+1),srcStr);
}
However, for the string result I probably have to use something else
than "malloc"?!
Secondly, how should the caller free the assigned memory again?
I'm sorry for this basic question, but I'm still a beginner in
programming with cygwin/gcc under WinNT.
Regards, Christian
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple