Correct use of memcpy in C -


i attempting copy content of error object deque, when check copied content, not correct.

typedef struct er_object {     uint8 error_type;      union     {         uint32 number;         char *message;     } error;  } er_object;  void er_copy(de_list *deque, er_object *object) {     er_object *marker;      marker = er_get_first_object(deque);      memcpy(object, marker, sizeof(*marker)); } 

everything , including function er_get_first_object works intended, ie can examine content of marker , correct. leads me believe problem lies memcpy.

if create second pointer er_object called marker2, , use memcpy copy content of marker marker2, works fine. when attempt copy content of marker external object error occurs.

would kind point out doing wrong?

unfortunately, posted code correct.

i "unfortunately" because means problem somewhere else in program. suggest using additional tools, such mudflap , valgrind.

  1. if using gcc, compile -fmudflap. requires mudflap libraries installed.
  2. run valgrind.

the tools overlap in purpose somewhat, there errors 1 of 2 tools catch.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -