Example #1
0
int main() 
{
  char **unique, filename[80], word[80];
  int counts[31], size = 10, i, count = 0;
  FILE *fp;
  unique = malloc(10 * sizeof(char*));
  printf("Filename: ");
  scanf("%s", filename);
  
  if((fp = fopen(filename, "r")) == NULL)
  {
    printf("Unable to read %s.\n", filename);
    return -1;
  }  // if not able to open file
  
  for(i = 0; i <= 30; i++)    
    counts[i] = 0;
  
  while(fscanf(fp, "%s", word) != EOF)
    unique = processWord(unique, counts, &size, &count, word);
  
  show_results(counts, count, size);
  free_unique(unique, count);
  
  return 0;
} // main()
Example #2
0
 variant_ptr<T, D> pop_variant(D d = D()) noexcept
 {
   auto e = pri_pop();
   if (e != nullptr)
   {
     if (e->shared())
     {
       ACTX_ASSERTS(!e->unique());
       auto ptr = e->free_shared();
       ACTX_ASSERTS(!!ptr);
       return std::move(variant_ptr<T, D>(std::static_pointer_cast<T>(ptr)));
     }
     else if (e->unique())
     {
       ACTX_ASSERTS(!e->shared());
       e->free_unique();
       return std::move(variant_ptr<T, D>(std::unique_ptr<T, D>(e)));
     }
     else
     {
       ACTX_ASSERTS(!e->unique());
       ACTX_ASSERTS(!e->shared());
       return std::move(variant_ptr<T, D>(e));
     }
   }
   return std::move(variant_ptr<T, D>());
 }
Example #3
0
 //! Pop an element from head.
 gsl::owner<T*> pop() noexcept
 {
   auto e = pri_pop();
   if (e != nullptr)
   {
     ACTX_ASSERTS(!e->shared());
     e->free_unique();
   }
   return e;
 }
Example #4
0
 std::unique_ptr<T, D> pop_unique(D d = D()) noexcept
 {
   auto e = pri_pop();
   if (e != nullptr)
   {
     ACTX_ASSERTS(!e->shared());
     e->free_unique();
   }
   return std::move(std::unique_ptr<T, D>(e, d));
 }