Exemplo n.º 1
0
/*.......................................................................
 * Delete a HashTable free-list. An error will be displayed if the list is
 * still in use and the deletion will be aborted.
 *
 * Input:
 *  mem    HashMemory *  The free-list container to be deleted.
 *  force         int    If force==0 then _del_HashMemory() will complain
 *                        and refuse to delete the free-list if any
 *                        of nodes have not been returned to the free-list.
 *                       If force!=0 then _del_HashMemory() will not check
 *                        whether any nodes are still in use and will
 *                        always delete the list.
 * Output:
 *  return HashMemory *  Always NULL (even if the memory could not be
 *                       deleted).
 */
HashMemory *_del_HashMemory(HashMemory *mem, int force)
{
  if(mem) {
    if(!force && (_busy_FreeListNodes(mem->hash_memory) > 0 ||
		  _busy_FreeListNodes(mem->node_memory) > 0)) {
      errno = EBUSY;
      return NULL;
    };
    mem->hash_memory = _del_FreeList(mem->hash_memory, force);
    mem->node_memory = _del_FreeList(mem->node_memory, force);
    mem->string_memory = _del_StringMem(mem->string_memory, force);
    free(mem);
  };
  return NULL;
}
Exemplo n.º 2
0
/*.......................................................................
 * Delete a GlCharQueue object.
 *
 * Input:
 *  cq     GlCharQueue *  The object to be deleted.
 * Output:
 *  return GlCharQueue *  The deleted object (always NULL).
 */
GlCharQueue *_del_GlCharQueue(GlCharQueue *cq)
{
  if(cq) {
    cq->err = _del_ErrMsg(cq->err);
    cq->bufmem = _del_FreeList(cq->bufmem, 1);
    free(cq);
  };
  return NULL;
}
Exemplo n.º 3
0
/*.......................................................................
 * Delete a ExpandFile object.
 *
 * Input:
 *  ef     ExpandFile *  The object to be deleted.
 * Output:
 *  return ExpandFile *  The deleted object (always NULL).
 */
ExpandFile *del_ExpandFile(ExpandFile *ef)
{
  if(ef) {
    DirNode *dnode;
/*
 * Delete the string segments.
 */
    ef->sg = _del_StringGroup(ef->sg);
/*
 * Delete the cached directory readers.
 */
    for(dnode=ef->cache.head; dnode; dnode=dnode->next)
      dnode->dr = _del_DirReader(dnode->dr);
/*
 * Delete the memory from which the DirNode list was allocated, thus
 * deleting the list at the same time.
 */
    ef->cache.mem = _del_FreeList("del_ExpandFile", ef->cache.mem, 1);
    ef->cache.head = ef->cache.tail = ef->cache.next = NULL;
/*
 * Delete the pathname buffer.
 */
    ef->path = _del_PathName(ef->path);
/*
 * Delete the home-directory lookup object.
 */
    ef->home = _del_HomeDir(ef->home);
/*
 * Delete the array of pointers to files.
 */
    if(ef->result.files) {
      free(ef->result.files);
      ef->result.files = NULL;
    };
/*
 * Delete the container.
 */
    free(ef);
  };
  return NULL;
}
Exemplo n.º 4
0
/*.......................................................................
 * Delete a string free-list.
 *
 * Input:
 *  sm       StringMem *  The string free-list to be deleted, or NULL.
 *  force          int    If force==0 then _del_StringMem() will complain
 *                         and refuse to delete the free-list if any
 *                         of nodes have not been returned to the free-list.
 *                        If force!=0 then _del_StringMem() will not check
 *                         whether any nodes are still in use and will
 *                         always delete the list.
 * Output:
 *  return   StringMem *  Always NULL (even if the list couldn't be
 *                        deleted).
 */
StringMem *_del_StringMem(StringMem *sm, int force)
{
  if(sm) {
/*
 * Check whether any strings have not been returned to the free-list.
 */
    if(!force && (sm->nmalloc > 0 || _busy_FreeListNodes(sm->fl) > 0)) {
      errno = EBUSY;
      return NULL;
    };
/*
 * Delete the free-list.
 */
    sm->fl = _del_FreeList(sm->fl, force);
/*
 * Delete the container.
 */
    free(sm);
  };
  return NULL;
}