File:  [CSRG BSD Unix] / 43BSD / contrib / icon / functions / delete.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#include "../h/rt.h"
#ifdef SETS
/*
 * delete(S,x) - delete element x from set S if it is there
 *  (always succeeds and returns S).
 */

Xdelete(nargs,arg2,arg1,arg0)
int nargs;
struct descrip arg0, arg1, arg2;
   {
   register struct descrip *pd;
   int res ;
   extern struct descrip *memb();

   DeRef(arg1)
   DeRef(arg2)
   arg0 = arg1;

   if (QUAL(arg1) || TYPE(arg1) != T_SET)
       runerr(119,&arg1);
      /*
      * The technique and philosophy here are the same
      *  as used in insert.c - see comment there.
      */
   pd = memb(BLKLOC(arg1),&arg2,hash(&arg2),&res);
   if (res == 1) {
      /*
      * The element is there so delete it.
      */
      *pd = BLKLOC(*pd)->selem.sblink;
      (BLKLOC(arg1)->set.setsize)--;
      }
   }

Procblock(delete,2)

#else SETS
char junk;			/* prevent null object file  */
#endif SETS

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.