Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: made BUFFER_SIZE a constant

...

Code Block
bgColor#FFCCCC
langc
#include <stdlib.h>
 
int f(void) {
  enum {const int BUFFER_SIZE = 32 };;

int f(void) {
  char *text_buffer = (char *)malloc(BUFFER_SIZE); 
  if (text_buffer == NULL) {
    return -1;
  }
  return 0;
}

...

Code Block
bgColor#ccccff
langc
#include <stdlib.h>

const 
int f(void) {
  enum { BUFFER_SIZE = 32 };;

int f(void) {
  char *text_buffer = (char *)malloc(BUFFER_SIZE); 
  if (text_buffer == NULL) {
    return -1;
  }
 
  free(text_buffer);
  return 0;
}

...

Code Block
bgColor#ccccff
langc
#include <stdlib.h>
 
int f(void) {
  enum {const int BUFFER_SIZE = 32 };

int f(void) {
  static char *text_buffer = (char *)malloc(BUFFER_SIZE); 
  if (text_buffer == NULL) {
    return -1;
  }
  return 0;
}

...