#Memory problem

31 messages · Page 1 of 1 (latest)

solar wagonBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

wary coyote
#

the arguments str malloc is like this (it's not the same name but i pass base in argument of my rope_insert_at function)

#

the problem is that with my realloc on "rope->inner_string->str", the new "size" seem to be good, so no problem with that but all the characters of the argument str are changed :

#

like this

#

and i can't understand why str characters are changed during the realloc (i'm not even mentionning str in the line)

wary coyote
#

it seem than passing by a new char seem to work :

#

but making a copy like this will reduce the speed of my code i think

keen siren
#

The root of this could be anything.
How about you compile with -g3 -fsanitize=address,undefined and just run the code and see what it tells you.
If that doesn't help then please share your entire code (as a codeblock, not as an image please).

wary coyote
keen siren
#

Well, then you could add these two compile options into your makefile

wary coyote
keen siren
#

yeah

wary coyote
#

i have a lot of things

#

i don't really understand all but i have a lot of things like this :

undefined reference to __asan_report_load8' undefined reference to __ubsan_handle_divrem_overflow'

keen siren
#

oh, are you not on Linux?

#

Just share your code, that'll be easier

wary coyote
#

i'm on linux but maybe i don't have all things installed, we gave me that project like this, i don't know a lot of c

#

i give just the function where i have problems?

keen siren
#

The function where you have the problems + all the other functions that touched the problematic piece before (I want to be able to see how it was created, assigned a value to, etc)

wary coyote
#

okay

#

there s a lot

#

Inner_string *inner_string_new(char *str, size_t lenstr)
{
Inner_string *inner_string = (Inner_string *)malloc(sizeof(Inner_string));
if (inner_string == NULL)
{
fprintf(stderr, "Erreur d'allocation mémoire pour la structure Inner_string\n");
exit(EXIT_FAILURE);
}
inner_string->str = str;
inner_string->length = lenstr;
return inner_string;
}

#

i don't have problems until rope_insert_at that break my mind

wary coyote
#

i'm maybe thinking than the first time i insert it work (except maybe ajust_inner_string_length that don't seem to work that much) and the other time it may make an error

wary coyote
#

ok so the problem came from the fact than my base variable is modify when i make the realloc even if i don't mention it inside of it

wary coyote
#

this is working now, it just seem that it s too slow for the moment

solar wagonBOT
#

@wary coyote

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

wary coyote
#

!solved