Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Segfault "Access not within mapped region at address 0x10" in RenderTarget::draw  (Read 9185 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Quote
    auto rc = (RenderableComponent *)malloc(sizeof(RenderableComponent));
    load_sprite(rc->sprite, "whatever.png");
malloc doesn't construct objects, it just allocates raw memory. In other words, the content of your rc variable is undefined. Never ever use malloc to instanciate objects in C++.
Laurent Gomila - SFML developer

anthonyy

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Oh my god. I ported this code from pure C, I had no idea. Thanks so much for your help. I can't believe I didn't realise  :'(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10989
    • View Profile
    • development blog
    • Email
Do a clean full rebuild.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

anthonyy

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
I've fixed it now, thanks :)

 

anything