Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5417

CVI 2013 "FATAL RUN-TIME ERROR: Pointer to free memory passed to library function" when accessing a struct from a struct

$
0
0
#include <utility.h>
#include <ansi_c.h>
#include <cvirte.h>

typedef struct StringsStruct
{
  char A[10];
  char AA[10];
  
  char B[10];
  char BB[10];
  
  char C[10];
  char CC[10];
} StringsStructType;

StringsStructType Strings = {0};

char *const SelectedStrings[3] =
{
  Strings.A,
  Strings.B,
  Strings.C
};

int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPSTR lpszCmdLine, int nCmdShow)
{
  if (InitCVIRTE (hInstance, 0, 0) == 0)
    return -1;    /* out of memory */
  
  strcpy( SelectedStrings[1], "TEXT" );
  /*** FATAL RUN-TIME ERROR:   "main.c", line 32, col 11, thread id 0xXXXXXXXX:   Pointer to free memory passed to library function. ***/
  
  Breakpoint();
  
  return 0;
}

Any chance to get this working in CVI 2013?

"&Strings.A[0]" doesn't work either.


Viewing all articles
Browse latest Browse all 5417

Trending Articles