C++ programmers: Do you mix malloc() and new[] within a single program?
-
C++ programmers: Do you mix malloc() and new[] within a single program?
@mcc TIL 60% of C++ programmers do not write C++
-
@mcc TIL 60% of C++ programmers do not write C++
@ratsnakegames Actually, that sounds accurate to me
-
@ratsnakegames Actually, that sounds accurate to me
@mcc C++ programmers: Do you write C++
-
@mcc C++ programmers: Do you write C++
@ratsnakegames I am writing C++ right now… I am experiencing distress
-
@ratsnakegames I am writing C++ right now… I am experiencing distress
@mcc my motto is "live your life so you can avoid writing C++ at all costs"
-
C++ programmers: Do you mix malloc() and new[] within a single program?
The curse of being a C++ programmer: pedantically wondering if this is specifically referring to array new which pretty much everyone agrees should never be used and is dramatically less common in c++ code than malloc is. (Doesn't change the "only under duress" answer though)
-
C++ programmers: Do you mix malloc() and new[] within a single program?
@mcc When writing C++ I use calloc and free. I worked on a project years ago where I'd been doing that and a new recruit came in and started using "new/delete" instead and we quickly ran into memory issues.
Mostly the problems were due to the newbie not knowing that some behaviour of "new" is undefined and not all implementations of it zero memory.
-
C++ programmers: Do you mix malloc() and new[] within a single program?
@mcc I avoid new at all costs. I use make_shared/make_unique for objects, and vector for arrays.
-
C++ programmers: Do you mix malloc() and new[] within a single program?
@mcc@mastodon.social I have written C++, but honestly very very little. Was trying to sort out some stuff, and never made it far, so I don't write C++.
-
C++ programmers: Do you mix malloc() and new[] within a single program?
@mcc You use neither!
make_unique as a last resort if vector/string or array etc do not work. and when, tightly encapsulated and well unit tested.
see my C++ Expert level training. material observable on my github
-
undefined oblomov@sociale.network shared this topic
-
C++ programmers: Do you mix malloc() and new[] within a single program?
@mcc I try not to, but there are cases where you want lower level allocations (e.g. aligned), which technically are not malloc but I think fit the “not new[]” case