示例#1
0
文件: HTTP.c 项目: clach04/HTTP-Push
static void update_menu_data(int stringSize) {



  free_all_data();

  if (stringSize == 0) {return;}


  if (stringSize > 0) {
    char *buf= malloc(255);
    int readByteSize = persist_read_string(PERSIST_LIST,buf,255);
    listString = malloc(readByteSize);
    memcpy(listString,buf,readByteSize);
    free(buf);
    buf = NULL;

    listSize = persist_read_int(PERSIST_LIST_SIZE);

    APP_LOG(APP_LOG_LEVEL_DEBUG, "Read list from persistent storage: %s", listString);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Read size (value) from persistent storage: %d", listSize);

  } else {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Processing stringSize: %i",stringSize);
    listSize = stringSize;
    listString = (char*)malloc((strlen(s_buffer)+1)*sizeof(char));
    memcpy(listString, s_buffer, (strlen(s_buffer)+1)*sizeof(char));
    //strcpy(listString,s_buffer);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "strlen(listString): %i",strlen(listString));
  }

  theList = malloc(listSize * sizeof(char*));
  statusList = malloc(listSize * sizeof(char*));

  char * pch = NULL;
  int i;
  i = 0;
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Splitting string \"%s\" into tokens",listString);
  pch = strtok (listString,",");
  APP_LOG(APP_LOG_LEVEL_DEBUG, "strtok'd");

  while (pch != NULL)
  {
    theList[i] = (char*)malloc((strlen(pch)+1) * sizeof(char)); // Add extra for end char
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Malloc'd");
    statusList[i] = "Ready";
    memcpy(theList[i++],pch,(strlen(pch)+1) * sizeof(char));
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Mem copied");
    pch = strtok (NULL, ",");
  }

  for (i=0;i<listSize; ++i) 
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Data[%d]: %s",i, theList[i]);
  pch = NULL;
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Completed free all procedure");

  
}
示例#2
0
static int do_real_work(void) {
  pip_db_t *pipdb;
  alldata_t *dat;

  pipdb = build_pip_db(data);
  dat = fill_all_data(pipdb, ref, data);
  dat->width = width;

  /*
    Allocate the pip db state.
    Maybe this could be done at build_pip_db time, or use another
    dedicated structure.
  */
  alloc_pips_state(pipdb, dat);

  /* Work in full algebra -- this takes a long time */
  if (internal) {
    do_all_pips_internal(pipdb, dat, iterate);
    goto dump;
  }

  /* Intersect and conter-interset pips */
  if (thorough) {
    do_all_pips_thorough(pipdb, dat, iterate);
    goto dump;
  }

  /* Dumbest form of isolation, interset only */
  if (allelems) {
    do_all_pips(pipdb, dat);
    goto dump;
  }

  goto exit;

 dump:
  dump_pips_db(pipdb);
 exit:
  free_pips_state(pipdb);
  free_all_data(dat);
  free_pip_db(pipdb);
  return 0;
}