Search:

Type: Posts; User: notan

Search: Search took 0.00 seconds.

  1. Replies
    9
    Views
    2,422

    The only 'valid' wrapper for malloc that I can...

    The only 'valid' wrapper for malloc that I can think of is:



    void *alloc(size_t size)
    {
    void* mem;
    mem = malloc(size);
    if (!mem) {
    fprintf(stderr, "Out of memory!\n");
  2. No there is no difference in this case, as...

    No there is no difference in this case, as correctly stated in the FAQ:

    Rule 3:
    An array name in the declaration of a function parameter is
    treated by the compiler as a pointer to the first...
  3. Replies
    27
    Views
    16,549

    Closing an invalid file descriptor is not a bad...

    Closing an invalid file descriptor is not a bad thing, closing an again valid descriptor is where things go really bad. When you searched this kind of bug in VxWorks where filedescriptors are shared...
  4. Replies
    4
    Views
    3,779

    C treats the following definitions the same (sad...

    C treats the following definitions the same (sad but true).


    int foo(int bar[10]);
    int foo(int bar[]);
    int foo(int *bar);

    therefore sizeof bar is always the size of a single pointer (4 on...
  5. Well the 'obscure' thing is that C accepts ...

    Well the 'obscure' thing is that C accepts


    int foo(short bar[8])


    even as the number is redundant and unused. As the compiler does not care about the size of the array it shall insist on...
  6. Replies
    27
    Views
    16,549

    Nothing is the best case. Launching nukes is the...

    Nothing is the best case.
    Launching nukes is the worst case, but unfortunately not impossible.
    Be aware of closed handles and dangling pointers, they might send you straight to hell.
  7. Replies
    2
    Views
    797

    will loop infinitely when 0 is entered, use >1...

    will loop infinitely when 0 is entered, use >1 instead of !=1.
    You want to assign count the incremented value, thus ++ is on the wrong side.
    Ampersand missing at parameter for scanf.
    Will not work...
  8. Replies
    27
    Views
    16,549

    Closing the fd twice is dangerous and bad...

    Closing the fd twice is dangerous and bad practice, as closed file descriptors will be recycled later, therefore your second close may close a file opened by someone else in the meantime.
    I...
  9. Thread: need some advice

    by notan
    Replies
    6
    Views
    1,102

    The right way to program it is float a =...

    The right way to program it is


    float a = 0.7f;
    if (a > 0.7f) {
    /* you will not reach this hell */
    } else {
    /* this is the place we go */
    }
  10. Standard alternative to sizeof(array)/sizeof(array[0])?

    Is there a good standard alternative to the

    sizeof(array)/sizeof(array[0])
    used for determining the size of an array?

    Well sometimes you see:


    sizeof array/sizeof*array
Results 1 to 10 of 10