All pastes #769586 Raw Edit

Something

public text v1 · immutable
·published 2007-11-11 15:40 UTC
rendered paste body
#define __STEP__ 10

int getInput(char **ppTest)
{
  int length = 0;
  int input = 0;
  *ppTest = (char*)malloc(__STEP__+2);
  while(!(*ppTest) && (input = fgetc(stdin)) != EOF)
  {
    printf("middle : %c", input);
    if ( (__STEP__-1)==(length%__STEP__))
      {
        if (NULL==realloc((*ppTest), (length+1)/__STEP__+__STEP__+ 2))
          {
            free(*ppTest);*ppTest=NULL;
            return 0;
          }
      }
    (*ppTest)[length] = (char)input;
    ++length;
  }
  if(!(*ppTest))
    (*ppTest)[length] = '\0';
  printf("\n length : %i\n", length);
  return length;
}