Johnnei's World
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Sjmarf@sh.itjust.works to Programming Horror@programming.dev · 1 year ago

mallocPlusAI

sh.itjust.works

message-square
32
link
fedilink
245

mallocPlusAI

sh.itjust.works

Sjmarf@sh.itjust.works to Programming Horror@programming.dev · 1 year ago
message-square
32
link
fedilink
  • zaphod@sopuli.xyz
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    1 year ago

    You don’t need to cast the return value from malloc.

    • addie@feddit.uk
      link
      fedilink
      arrow-up
      10
      arrow-down
      1
      ·
      1 year ago

      True. Although given how easy it is to cast void pointers to the wrong damn thing, it would be nice if you did, makes refactoring much easier. Makes me appreciate std::any all the more.

      • embed_me@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        Void pointer should be avoid anyways. Even I find them rare and I mostly work in embedded RTOS

    • Subverb@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      This isn’t malloc though. I have to assume the cast is because the user has experience with the output from an LLM being untrustworthy.

    • vrighter@discuss.tchncs.de
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      you do in c++, no?

      • zaphod@sopuli.xyz
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        In c++ you should use new.

        • vrighter@discuss.tchncs.de
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          that is besides the point. You can still call malloc, it will still return void*, and it would still reqoire casting in c++

Programming Horror@programming.dev

programming_horror@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programming_horror@programming.dev

Welcome to Programming Horror!

This is a place to share strange or terrible code you come across.

For more general memes about programming there’s also Programmer Humor.

Looking for mods. If youre interested in moderating the community feel free to dm @Ategon@programming.dev

Rules

  • Keep content in english
  • No advertisements (this includes both code in advertisements and advertisement in posts)
  • No generated code (a person has to have made it)

Credits

  • Icon base made by Lorc under CC BY 3.0 with modifications to add a gradient
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 2 users / day
  • 2 users / week
  • 2 users / month
  • 139 users / 6 months
  • 1 local subscriber
  • 2.33K subscribers
  • 45 Posts
  • 289 Comments
  • Modlog
  • mods:
  • Vacant@programming.dev
  • UI: 0.19.16
  • BE: 0.19.17
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org