News for hackers. Stuff that matters.

pfacka

Re:Guide to Advanced Programming in C on Friday February 07, 2014 @05:02AM (#7195563)
Noted, thanks, failed allocation is definitely good candidate for fail fast scenario.
Re:Guide to Advanced Programming in C on Friday February 07, 2014 @04:43AM (#7195516)
That is because to my knowledge we does not have something like "crealloc" to grow allocated memory effectively. Naive implementation of such function will lead always to coping memory from old to new area and effective would far more difficult to implement (thus more error prone IMHO).
Re:Guide to Advanced Programming in C on Friday February 07, 2014 @04:24AM (#7195470)
True, but return type of free() is void, thus it says nothing about return value. The POSIX says: "If size is 0, either a null pointer or a unique pointer that can be successfully passed to free() shall be returned."
Re:Guide to Advanced Programming in C on Friday February 07, 2014 @03:36AM (#7195327)
Thanks, I tested with GCC and Clang on Linux on 64-bit x86, GCC+OpenBSD on 32-bit+x86 and GCC+Linux on PowerPC 603. The point I was aiming for is that described operation is indeed undefined.
Re:Guide to Advanced Programming in C on Friday February 07, 2014 @03:19AM (#7195298)
It seems that I have totally messed up whole vector example by last minute changes. The check was meant to illustrate what eliteraspberrie described in previous comment.
Re:Guide to Advanced Programming in C on Friday February 07, 2014 @03:09AM (#7195277)
I agree that wording is bit unclear. I will try to find better one, thanks.
Re:Guide to Advanced Programming in C on Thursday February 06, 2014 @06:13PM (#7193573)
Thanks, for pointing out
Re:Guide to Advanced Programming in C on Thursday February 06, 2014 @06:06PM (#7193528)
Yep, that is definitely error
Re:Guide to Advanced Programming in C on Thursday February 06, 2014 @05:47PM (#7193427)
The challenging part is to get details of using them correctly and avoid security and portability issues and I consider it neccesaty introduction for section dealing with memory management.
Re:Guide to Advanced Programming in C on Thursday February 06, 2014 @05:31PM (#7193362)
I see, but could you please provide better alternative? I couldn't find anything more alive and representative than Boehm GC.