Re: __declspec(dllexport) to return char but errors in VB6



>Can any one explain what I am doing wrong?

The pointer you're returning is invalid since you just freed the
memory it points to.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.



Relevant Pages

  • Re: Simple question, err... I think
    ... One assumption is then that client code should leak memory. ... Given that there's no deallocation for these RB trees, ... a pointer to an invalid tree and it might segfault. ...
    (comp.programming)
  • Re: Reading from invalid memory
    ... from the same invalid memory location I do not get any errors. ... since constructing or dereferencing an invalid pointer ... Undefined behavior can be anything, ...
    (comp.unix.programmer)
  • Re: segmentation fault in strcmp()
    ... What is the meaning of such an error like invalid next size/ ... It means that the freeis trying to figure out the size of the next block of memory in the heap; information it needs in order to complete the process of freeing the memory you've asked it to release. ... Since the place where it looks is determined in part by the pointer that you pass to free, one possibility is that you're passing the wrong pointer to free; ... If p is not a pointer returned by a call to malloc() or realloc), then freecould cause this problem. ...
    (comp.lang.c)
  • Re: validity of a pointer
    ... only "invalid" pointer in terms of C is the null pointer, ... An indeterminate pointer is more invalid than a null pointer. ... However dereferencing a null pointer is invalid, ... Without a operating system, memory protection ...
    (comp.lang.c)
  • Re: Checking pointers
    ... know is that the pointer points "where it ought to," which is much harder to characterize. ... Using assorted non-portable tricks you might be able to learn whether a pointer points to a valid memory location, whether it's correctly aligned for its type, whether the memory is readable and/or writeable, and maybe other things, too. ... your test is reliable only if `p' is valid; if `p' is invalid there is no telling what might happen. ... I have not personally used things like Purify or valgrind and cannot speak to their effectiveness -- but certainly a "spot-check" test unsupported by considerable additional machinery is of limited effectiveness.) ...
    (comp.lang.c)