Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.19 seconds.

  1. Replies
    2
    Views
    57

    The problem is that if you're only keeping track...

    The problem is that if you're only keeping track of the head, it's rather inefficient to append to the linked list in a loop as you have to keep traversing the entire linked list on each iteration.
    ...
  2. Ah, since you understand that the return value is...

    Ah, since you understand that the return value is used to compute the new value of x rather than being x, you have it right.
  3. The problem is that sequences() allocates new...

    The problem is that sequences() allocates new memory on each call, but you're overwriting Allseqs with its return value. Therefore, the previous value of Allseqs is lost, resulting in a memory leak...
  4. That's not the right fix though: now we would...

    That's not the right fix though: now we would expect you to be working with an array of pointers to short, not an array of shorts. Look carefully at how Hodor declared the array named data in main in...
  5. Not hard to find security vulnerabilities listed...

    Not hard to find security vulnerabilities listed related to null termination, or rather the lack thereof.


    That's because for linked lists and many other tree structures, having a sentinel value...
  6. Don't be lazy and trawl the CVE list yourself.

    Don't be lazy and trawl the CVE list yourself.
  7. Replies
    15
    Views
    340

    While it does involve reference counting, that...

    While it does involve reference counting, that technique is more specifically called copy-on-write.
  8. Yes. Alternatively, you can pass a second pointer...

    Yes. Alternatively, you can pass a second pointer that points to one past the end of the range that you want the function to access. Yet another possibility is that it may make sense to wrap both the...
  9. Replies
    9
    Views
    181

    I didn't say fread doesn't read from stdin's...

    I didn't say fread doesn't read from stdin's buffer; I said that fread doesn't read from its own buffer. It's true that I carefully avoided using the phrase "stdin's buffer", and that's because...
  10. Replies
    9
    Views
    181

    No, as you correctly wrote later, it reads from...

    No, as you correctly wrote later, it reads from stdin into its own buffer.


    What exactly fread does is implementation defined by definition, but for efficiency it's likely to read in chunks of...
  11. Replies
    9
    Views
    181

    No. fread reads from stdin into its own buffer....

    No. fread reads from stdin into its own buffer. It is likely implemented using operating system specific API calls (and is meant to handle binary data, not just text), but you can imagine it being...
  12. Replies
    9
    Views
    181

    fread has its own buffer, i.e., the memory of the...

    fread has its own buffer, i.e., the memory of the objects that you are trying to read into. So, fread doesn't have to read everything at once, and so it doesn't have to know beforehand how many...
  13. I guess upgrading compiler isn't an option then...

    I guess upgrading compiler isn't an option then :)

    Unfortunately in your real code, this could be due to undefined behaviour interacting with compiler optimisation, rather than a compiler bug. But...
  14. What version of gcc did you use to compile?

    What version of gcc did you use to compile?
  15. Since it is impossible to assign to 0, I'm...

    Since it is impossible to assign to 0, I'm guessing you mean the opposite, that is, this line?

    buffer[strcspn(buffer,"\n")] = 0;
    If so, that's weird: the statement is not a candidate to be...
  16. Replies
    8
    Views
    198

    Doing that reinterprets an object of one type as...

    Doing that reinterprets an object of one type as being of another type via pointers, and isn't what you want here. What you're probably thinking of is a pointer to void, but that is not type safe,...
  17. No. Since q is a parameter, it is assigned a...

    No. Since q is a parameter, it is assigned a value every time the function is called, i.e., its value is the corresponding argument passed to the function.


    foo(x) is an expression that means a...
  18. Replies
    15
    Views
    340

    You cannot implicitly convert a pointer to a...

    You cannot implicitly convert a pointer to a String to a reference to a String; that's why you need to dereference the pointer to get a String object for the String reference to refer to.


    Just...
  19. Replies
    8
    Views
    198

    I think that this is the fundamental problem: you...

    I think that this is the fundamental problem: you should make Player a polymorphic base class, defining a common interface that Knight and Cowboy can both implement, and which will be used by the...
  20. Replies
    15
    Views
    340

    If all you want to do is avoid a possible copy...

    If all you want to do is avoid a possible copy constructor call, then indeed the second example is better (if you return *string instead), but it is also so error-prone that you should live with the...
  21. Replies
    8
    Views
    198

    A few stylistic issues to address: [list] You...

    A few stylistic issues to address:
    [list]
    You didn't provide the code that shows what are the types involved, but I'm going to guess that CowboyPtr and WeaponPtr are just typedefs for Cowboy* and...
  22. I think when the requirements ask for you to pass...

    I think when the requirements ask for you to pass multiple time structs, they mean multiple objects (or pointers thereof) of the same time struct type, not three time struct types that are identical...
  23. Replies
    4
    Views
    550

    C11 only specifies these encoding prefixes for...

    C11 only specifies these encoding prefixes for string literals: u8, u, U, L. Hence, your b# and B# encoding prefixes would not conflict as a language extension.

    The syntax specified by the...
  24. Thread: Slow forum?

    by laserlight
    Replies
    11
    Views
    490

    Seems to be working for now.

    Seems to be working for now.
  25. What do you think is the problem and what have...

    What do you think is the problem and what have you tried for debugging, e.g., have you stepped through the loop with a debugger?
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4