Louis :emacs: on Nostr: npub18g4k0…2n4gd Case 1: realloc could extend the memory block buf points to, it ...
npub18g4k0gljynatgs2anultm3y55tmd2qjxra8wgywe8nqr3cr26g4qe2n4gd (npub18g4…n4gd) Case 1: realloc could extend the memory block buf points to, it will return a pointer to buf
Case 2: realloc could not extend buf, but found a new memory block big enough, it copies the contents of buf to a new block, frees buf and returns pointer to the new block
Case 3: realloc could not find any memory, it will just return NULL
So in your case, you should just check for outp == NULL and then continue to work with outp, because it will be either Case 1 (the same memory block) or Case 2 ( a new memory block with the contents of the old memory block ).
Case 2: realloc could not extend buf, but found a new memory block big enough, it copies the contents of buf to a new block, frees buf and returns pointer to the new block
Case 3: realloc could not find any memory, it will just return NULL
So in your case, you should just check for outp == NULL and then continue to work with outp, because it will be either Case 1 (the same memory block) or Case 2 ( a new memory block with the contents of the old memory block ).