« first day (290 days earlier)      last day (2569 days later) » 
01:00 - 18:0018:00 - 22:00

6:00 PM
sorry for caps
==27402==ERROR: LeakSanitizer: detected memory leaks
I just added exit(0); after removing entities
 
@SzymonMarczak you use std::vector<std::unique_ptr<Entity>>
 
because if I don't, asan will think: "entity isn't deleted, maybe the program will delete it later" (as someone said)
@milleniumbug I'm gonna do this. Your advices are amazingly helpful ;-)
ASAN told me there's memory leak in std::set
I understand that by reading the log
 
what's the c++ way to prevent the leak here?
string name ((char*)xmlNodeGetContent(node));
 
@RaviUpadhyay what does xmlNodeGetContent do
 
@milleniumbug @nwp pastebin.com/GxKwPw4u
 
6:05 PM
returns xmlChar* (which is char*)
 
"Indirect leak"
@SzymonMarczak do you store a std::set in a newd object
 
yes
is it bad?
 
well, then
 
noone told me that stroing set in newd object is bad :(
 
6:07 PM
nah
your newd object is leaked, and so the std::set contained within
 
so where the problem may be?
 
stop leaking your objects
 
I'll try :P
 
@RaviUpadhyay ok, so it clearly allocates a buffer
or maybe not, what do the docs say?
 
yeah it does. I'm thinking of doing,
string name (temp=(char*)xmlNodeGetContent(node)); free(temp);
 
6:09 PM
@milleniumbug but if I remove set from Entity, after the process exits ASAN says nothing
 
@RaviUpadhyay so it needs to be freed?
ok
    struct xmlFree_deleter
    {
        void operator()(char* ptr) { xmlFree(ptr); }
    };

    // ...

    std::unique_ptr<char, free_deleter> content(xmlNodeGetContent(node));
    string name(content.get());
@RaviUpadhyay ^ like this
hey, it's actually xmlFree
 
@milleniumbug @ratchetfreak told that using smart pointers means the code isn't working properly (or something like that) but I don't think he's right in 100%
 
he was referring to std::shared_ptr
not std::unique_ptr
 
@milleniumbug Oh, I see :D
Ok, then, I will use std::vector<std::unique_ptr<Entity>>
 
@milleniumbug hmm so xmlFree might have some other implementation. carelessly used free till now. btw it can return null, so i guess i can't use any compact way to do it. but thanks for the tip.
 
6:18 PM
@milleniumbug I know what was leaked. Client instance. I'm 99.99% sure. I messed up with mutexes
 
How can I convert a BinaryBuffer to int*?
 
what is a BinaryBuffer
 
std::vector<unsigned char>
 
what's the representation and the endianess of the numbers stored in the buffer
 
What do you mean by the representation of the numbers
 
6:28 PM
you can't just shove arbitrary bytes into an int sequence
so your byte sequence is probably serialized in a specific way
and now you're trying to deserialize it
in order to use it in the program
for example "32 bit unsigned little endian"
or "16 bit two's complement big endian"
 
I have a interface:

union FwdType;

class A {
virtual const fwdType& getSome() = 0;
}

And a derived class in another file:

class B : public A
{
}
fuck
let me try again
 
"fixed font" button
 
long
line test
wow it works :P
 
@milleniumbug I see...
 
is there any way in c++ to use an existing cstring without doing any malloc for cstring portion of string object?
 
6:37 PM
@PichiWuana basically you need to figure out where are you getting your buffer from, and what are they storing in it
@RaviUpadhyay ?
not sure what you're asking, can you provide more detail
you can avoid creating a new brand std::string if you operate on std::string_view or boost::string_spans
but these don't provide a way to modify the underlying string
 
I have this situation: https://pastebin.com/z61QaJtV

But I get this error every time I try to use the derived class:
C2371: 'FwdType': redefinition; different basic type

What am I doing wrong? This made sense to me, but apparently it is not good enough for the compiler
 
@milleniumbug the constructors for string, make a copy of provided string/char*
looking for a way to avoid a new copy.
 
std::string will always copy
 
you may use the std::unique_ptr directly
and assign to a std::string_view or boost::string_span
 
6:40 PM
let me read it up
 
...but, of course, only if you only read the string
not if you modify it
 
with unique_ptr modification is not allowed?
ahh, unique pointer can't point to char*?
 
no, with std::string_view
but if you want to modify it, I'd rather copy it in the first place to std::string
null-terminated C strings are reaaaaaaally annoying to operate on
@Horttanainen your code doesn't compile, that's one thing
another one is that you can't complete an incomplete type with a typedef
2
Q: Why can't I complete the type with the typedef?

milleniumbugGiven an incomplete type in translation unit A: struct Incomplete; Incomplete* create_incomplete(); void destroy_incomplete(Incomplete*); why can't I use it in another translation unit, by using typedef? For example in translation unit B: struct Unrelated { int x; int y; }; typedef...

also are you seriously using unions
 
@milleniumbug I've checked the problem. I messed up with mutexes
 
@milleniumbug That code is just something I wrote directly to the pastebin. The implementation is behind the #include "SomeOtherType.h".
 
6:53 PM
9 mins ago, by milleniumbug
another one is that you can't complete an incomplete type with a typedef
 
@milleniumbug I understand the problem now
Thanks
And I am using unions because the forward declared type is from an ancient library
 
how do I erase element from map?
map.earse(key) ?
 
yes
.erase
(of course this assumes your stored values don't need special treatment and aren't special snowflakes like owning raw pointers, IOW the newd objects pointed by T*)
 
 
2 hours later…
8:39 PM
couple of hours after testing, is it possible to have a virtual type alias? ie, a typedef that overrides a parent typedef?
i know i'm going insane, and i'm sorry
 
no
typedefs are always compile time
 
hm
is there anyway to know the child type from a pointer to base class object?
exploiting c++ doesn't appear to work well
yes, it's possible
that's all i need
 
you sir are a baws
my machine will work now
 
01:00 - 18:0018:00 - 22:00

« first day (290 days earlier)      last day (2569 days later) »