Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##(削除) Empty mallocs (削除ここまで)

(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##(削除) Const-correctness (削除ここまで)

(削除) Const-correctness (削除ここまで)

static char *END_CHK = "\xDE\xAD\xC0\xDA";

(削除) You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it) (削除ここまで)

(削除) Uninitialized variables (削除ここまで)

##(削除) Uninitialized variables (削除ここまで)(削除) active_size is still uninitialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

Data types

##Data types WhyWhy is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

Out of bounds

##Out of bounds ifif the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

##(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##(削除) Const-correctness (削除ここまで)

static char *END_CHK = "\xDE\xAD\xC0\xDA";

(削除) You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it) (削除ここまで)

##(削除) Uninitialized variables (削除ここまで)(削除) active_size is still uninitialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

(削除) Const-correctness (削除ここまで)

static char *END_CHK = "\xDE\xAD\xC0\xDA";

(削除) You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it) (削除ここまで)

(削除) Uninitialized variables (削除ここまで)

(削除) active_size is still uninitialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

Data types

Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

Out of bounds

if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

striking out my bad advice, again...
Source Link
Snowbody
  • 8.7k
  • 25
  • 50

##(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##Const-correctness##(削除) Const-correctness (削除ここまで)

static char *END_CHK = "\xDE\xAD\xC0\xDA";

You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it)(削除) You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it) (削除ここまで)

##(削除) Uninitialized variables (削除ここまで) (削除) active_size is still unintializeduninitialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

##(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##Const-correctness

static char *END_CHK = "\xDE\xAD\xC0\xDA";

You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it)

##(削除) Uninitialized variables (削除ここまで) (削除) active_size is still unintialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

##(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##(削除) Const-correctness (削除ここまで)

static char *END_CHK = "\xDE\xAD\xC0\xDA";

(削除) You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it) (削除ここまで)

##(削除) Uninitialized variables (削除ここまで) (削除) active_size is still uninitialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

strikign out inaccuracy pointed in comment
Source Link
Snowbody
  • 8.7k
  • 25
  • 50

##Empty mallocs##(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though).(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##Const-correctness

static char *END_CHK = "\xDE\xAD\xC0\xDA";

You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it)

##(削除) Uninitialized variables (削除ここまで) (削除) active_size is still unintialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

##Empty mallocs

 if(sz == 0 || sz > Heap_Capacity)

It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though).

##Const-correctness

static char *END_CHK = "\xDE\xAD\xC0\xDA";

You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it)

##(削除) Uninitialized variables (削除ここまで) (削除) active_size is still unintialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

##(削除) Empty mallocs (削除ここまで)

 if(sz == 0 || sz > Heap_Capacity)

(削除) It is actually legal to call the standard library's malloc() with an argument of 0, and you are guaranteed to get a unique pointer when you do (you can't do anything with it though). (削除ここまで)

##Const-correctness

static char *END_CHK = "\xDE\xAD\xC0\xDA";

You mean static char const * right? String literals are char const * not char * (though the compiler won't warn you about it)

##(削除) Uninitialized variables (削除ここまで) (削除) active_size is still unintialized at the time of first access. Didn't the compiler warn you about this? (削除ここまで)

##Data types Why is heap defined as being a uint64_t [], but then always accessed by casting to a char *, and sometimes a header *?

##Out of bounds if the heap is almost full, you check to see if there's enough space for the header and the requested memory...and then you write 5 extra bytes after that. You could end up writing past the bounds of heap.

##Running time

while(block->next != NULL)
{
 block = block->next;
}

The more memory you allocate, the longer and longer each malloc will take. You need a better data structure.

fixed formatting
Source Link
Snowbody
  • 8.7k
  • 25
  • 50
Loading
struck out inaccuracy
Source Link
Snowbody
  • 8.7k
  • 25
  • 50
Loading
Source Link
Snowbody
  • 8.7k
  • 25
  • 50
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /