Sponsored Content
Top Forums Programming Pointer to a struct (with pointers) *** glibc detected *** double free Post 302264943 by otheus on Friday 5th of December 2008 07:31:43 AM
Old 12-05-2008
I think the code looks okay (but I'm not a C++ expert). It could be that x and y no longer hold the original reference to your allocated arrays. In that case, the pointers might point somewhere they did not originally. Try this: after instantiating the m_Genes object, create a "shallow copy" of it, then before you distruct, compare the shallow copy with the m_Genes copy. If there's a difference in pointer values, that might be your problem.

Another possibility just occurred to me: It could be that you made a shallow copy of m_Genes and deleted the shallow copy as if it were a deep copy. That is, you already freed the pointers in m_Genes->x and ->y.
 

10 More Discussions You Might Find Interesting

1. Programming

*** glibc detected *** free(): invalid next size (normal): 0x0000000000503e70 ***

hi, I have made a small C program that make use of malloc and free for processing bitmap images. when i try to run the program, I am getting a error something like *** glibc detected *** free(): invalid next size (normal): 0x0000000000503e70 *** I am not sure of which free() is causing this... (1 Reply)
Discussion started by: vbreddy
1 Replies

2. Programming

*** glibc detected *** double free or corruption: 0x40236ff4 ***

when i try to use the class i wrote, i either get this: *** glibc detected *** double free or corruption: 0x40236ff4 *** and the proccess exits with an error code of 0; or it segfaults. could someone look at my header file (with imp.) to give me some insight as to why its not working? ... (19 Replies)
Discussion started by: norsk hedensk
19 Replies

3. Homework & Coursework Questions

C++ struct pointers & functions

Hi All, My latest assignment (practice not coursework!) is to write prototype interactive exam/test console application. I've used structs to store the question information (not sure if this was the best way to do it?) and I have the following code that outputs each question and it's possible... (0 Replies)
Discussion started by: pondlife
0 Replies

4. Homework & Coursework Questions

Passing pointers to struct

Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function... (2 Replies)
Discussion started by: ignatius3
2 Replies

5. Programming

Using pointers to struct members as args to functions

In a well-known book on the C language, there is an example of an efficient method for using a struct member as an argument to a function. (I'm a C noob, but I believe the correct terminology might be: use call-by-reference instead of call-by-value.) The function is printf. Anyway, here's a... (5 Replies)
Discussion started by: uiop44
5 Replies

6. Programming

Pointer to pointers

Hi guys, I'm trying to understand pointers in C and made a simple example and I've problems with It. Can someone help? #include <stdio.h> #include <stdlib.h> #include <assert.h> int f1(char **str_); int main(int argc, char **argv) { char *str = NULL; f1(&str); ... (3 Replies)
Discussion started by: pharaoh
3 Replies

7. Programming

*** glibc detected *** : malloc(): memory corruption (fast)

Hi Friends, while executing the below code, am getting *** glibc detected *** ./ok: malloc(): memory corruption (fast) error, please suggest how to solve this issue. #include <stdio.h> #include <string.h> #include <sqlca.h> #include <alloca.h> /* Define constants for VARCHAR... (2 Replies)
Discussion started by: mpjobsrch
2 Replies

8. Programming

*** glibc detected *** ./a.out malloc() memory corruption

I am facing a problem of memory corruption. The loop runs for the first time but does not go through the second time. What could be the problem? for(int z=0;z<2;z++) { fp=fopen("poly.dat","r"); /*do something which reads this file into a 2D array*/ fclose(fp); ... (10 Replies)
Discussion started by: dare
10 Replies

9. Programming

C++ glibc detected double free or corruption(!prev) using shared library

Currently I test a shared library vendor provided in linux , the following is the simple source : #include <iostream> using namespace std; extern int test1(); extern int test2(); int main() { cout << "hello world" << endl ; return 0 ; cout << "Test 1" << endl; ... (6 Replies)
Discussion started by: barfatchen
6 Replies

10. Homework & Coursework Questions

FORTRAN error *** glibc detected ***

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm doing aproximation of derivative called five-point stencil. For every value of x, in interval , in step... (0 Replies)
Discussion started by: antonija
0 Replies
PPATH_NUMBER(3) 					   BSD Library Functions Manual 					   PPATH_NUMBER(3)

NAME
ppath_number, ppath_copydel_int64, ppath_copyset_int64, ppath_set_int64, ppath_get_int64, ppath_delete_int64, ppath_copydel_uint64, ppath_copyset_uint64, ppath_set_uint64, ppath_get_uint64, ppath_delete_uint64 -- integer property path operations LIBRARY
library ``libppath'' SYNOPSIS
#include <ppath/ppath.h> int ppath_copydel_int64(prop_object_t, prop_object_t *, const ppath_t *); int ppath_copyset_int64(prop_object_t, prop_object_t *, const ppath_t *, int64_t); int ppath_set_int64(prop_object_t, const ppath_t *, int64_t); int ppath_get_int64(prop_object_t, const ppath_t *, int64_t *); int ppath_delete_int64(prop_object_t, const ppath_t *); int ppath_copydel_uint64(prop_object_t, prop_object_t *, const ppath_t *); int ppath_copyset_uint64(prop_object_t, prop_object_t *, const ppath_t *, uint64_t); int ppath_set_uint64(prop_object_t, const ppath_t *, uint64_t); int ppath_get_uint64(prop_object_t, const ppath_t *, uint64_t *); int ppath_delete_uint64(prop_object_t, const ppath_t *); DESCRIPTION
The ppath_number routines read, write, or delete integers in a property list by path. FUNCTIONS
ppath_number provides these functions for manipulating integers in a property list by the integers' paths: ppath_copydel_int64(prop_object_t o, prop_object_t *op, const ppath_t *p) ppath_copydel_uint64(prop_object_t o, prop_object_t *op, const ppath_t *p) Create a copy of the property list o at *op. Delete from the copy the prop_number_t named by p. If *op is NULL, ppath_copydel_int64() and ppath_copydel_uint64() create a shallow copy of o at *op. If *op is not NULL, ppath_copydel_int64() and ppath_copydel_uint64() expect for *op to be an existing shallow copy of o. For the purposes of ppath_copydel_int64() and ppath_copydel_uint64(), *op is a shallow copy of property list o if equal properties at equal paths are shared between the two. Before ppath_copydel_int64() and ppath_copydel_uint64() modify a property shared by *op and o, they create a private copy of the property for *op. ppath_copyset_int64(prop_object_t o, prop_object_t *op, const ppath_t *p, int64_t v) ppath_copyset_uint64(prop_object_t o, prop_object_t *op, const ppath_t *p, uint64_t v) Create a copy of the property list o at *op. In the copy, replace with v the prop_number_t named by p. If *op is NULL, ppath_copyset_int64() and ppath_copyset_uint64() create a shallow copy of o at *op. If *op is not NULL, ppath_copyset_int64() and ppath_copyset_uint64() expect for *op to be an existing shallow copy of o. For the purposes of ppath_copyset_int64() and ppath_copyset_uint64(), *op is a shallow copy of property list o if equal properties at equal paths are shared between the two. Before ppath_copydel_int64() and ppath_copydel_uint64() modify a property shared by *op and o, they create a private copy of the property for *op. ppath_set_int64(prop_object_t o, const ppath_t *p, int64_t v) ppath_set_uint64(prop_object_t o, const ppath_t *, uint64_t v) Replace with v the prop_number_t in o named by p. ppath_get_int64(prop_object_t o, const ppath_t *p, int64_t *vp) ppath_get_uint64(prop_object_t o, const ppath_t *p, uint64_t *vp) Retrieve the prop_number_t named by p from o, and write it to *vp. ppath_delete_int64(prop_object_t o, const ppath_t *p) ppath_delete_uint64(prop_object_t o, const ppath_t *p) Delete the prop_number_t named by p from o. ppath_delete_int64() and ppath_delete_uint64() decrease by one the deleted number's ref- erence count. RETURN VALUES
ppath_number routines return 0 on success, and non-zero on error. ERRORS
[EFTYPE] A ppath_number operation returns EFTYPE when the object named by the path is not a prop_number_t. [ENOENT] ppath_number routines return ENOENT if the path p does not exist in o. [ENOMEM] ppath_set_int64(), ppath_set_uint64(), ppath_copyset_int64(), and ppath_copyset_uint64() return ENOMEM if there was insuf- ficient memory to complete the operation. SEE ALSO
ppath(3), ppath_data(3), ppath_object(3), ppath_string(3), proplib(3) HISTORY
The ppath_number property container path library first appeared in NetBSD 6.0. AUTHORS
David Young <dyoung@pobox.com> BSD
September 13, 2011 BSD
All times are GMT -4. The time now is 10:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy