# 2.11BSD#431 - /usr/src/new/PORT/B/src/bsmall/b1mem.c

##### Functions

    critoff           X
    criton            X
    denote            X
    freemem           X
    getmem            X
    note              X
    regetmem          X
    sighold           X

##### Variables

    intrupted         X
    noting            X

##### Macros

    Note              X
    Plausible         X
    deNote            X

       1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
       2: /* $Header: b1mem.c,v 1.2 84/07/19 14:09:35 guido Exp $ */
       3:
       4: /* B memory management */
       5:
       6: #include "b.h"
       7: #include "b1obj.h"
       8: #include "b1mem.h"
       9:
      10: #define Plausible(syze) {if ((int) (syze) < 0) \
      11:     error("creating value of exceedingly large size");}
      12:
      13: #define Note(p) /* note(p) */
      14: #define deNote(p) /* denote(p) */
      15:
      16: Visible ptr getmem(syze) unsigned syze; {
      17:     ptr p;
      18:     Plausible(syze);
      19:     p= (ptr) malloc(syze);
      20:     Note(p);
      21:     if (bugs || p==Nil) printf("{%u}",syze);
      22:     if (p == Nil) memexh();
      23:     return p;
      24: }
      25:
      26: Visible Procedure regetmem(v, syze) value *v; unsigned syze; {
      27:     Plausible(syze);
      28:     uniql(v);
      29:     if (bugs) printf("[%u]",syze);
      30:     criton();
      31:     deNote((ptr)*v);
      32:     *v= (value) realloc((ptr) *v, syze);
      33:     Note((ptr)*v);
      34:     critoff();
      35:     if ((ptr) *v == Nil) memexh();
      36: }
      37:
      38: Visible Procedure freemem(p) ptr p; {
      39:     deNote(p);
      40:     free(p);
      41: }
      42:
      43: value notel; bool noting=Yes;
      44:
      45: Hidden Procedure note(p) int p; {
      46:     if (!noting) {
      47:         value ip;
      48:         noting= Yes;
      49:         insert(ip= mk_integer(p), &notel);
      50:         release(ip);
      51:         noting= No;
      52:     }
      53: }
      54:
      55: Hidden Procedure denote(p) int p; {
      56:     if (!noting) {
      57:         value ip;
      58:         noting= Yes;
      59:         if (!in(ip= mk_integer(p), notel))
      60:             syserr("releasing illegally");
      61:         remove(ip, &notel);
      62:         release(ip);
      63:         noting= No;
      64:     }
      65: }
      66:
      67: /*
      68:  * Hack to delay (but not ignore) interrupts during realloc calls.
      69:  */
      70:
      71: #include <signal.h>
      72:
      73: Hidden int (*inthandler)();
      74: Hidden bool intrupted;
      75:
      76: Hidden Procedure sighold(sig) int sig; {
      77:     signal(sig, sighold);
      78:     intrupted= Yes;
      79: }
      80:
      81: Hidden Procedure criton() {
      82:     intrupted= No;
      83:     inthandler= signal(SIGINT, sighold);
      84: }
      85:
      86: Hidden Procedure critoff() {
      87:     signal(SIGINT, inthandler);
      88:     if (intrupted && inthandler != SIG_IGN && inthandler != SIG_DFL)
      89:         (*inthandler)(SIGINT);
      90:     intrupted= No;
      91: }

#### Defined functions

critoff defined in line 86; used 1 times

- in line 34

criton defined in line 81; used 1 times

- in line 30

denote defined in line 55; never used
freemem defined in line 38; used 5 times

- in /usr/src/new/PORT/B/src/bsmall/B1val.c line 257, 270, 279
- in /usr/src/new/PORT/B/src/bsmall/b2sou.c line 403
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 383

getmem defined in line 16; used 5 times

- in /usr/src/new/PORT/B/src/bsmall/B1val.c line 64
- in /usr/src/new/PORT/B/src/bsmall/b1mem.h line 9
- in /usr/src/new/PORT/B/src/bsmall/b2sou.c line 396
- in /usr/src/new/PORT/B/src/bsmall/b2uni.c line 321, 551

note defined in line 45; never used
regetmem defined in line 26; used 3 times

- in /usr/src/new/PORT/B/src/bsmall/B1val.c line 94, 293, 302

sighold defined in line 76; used 2 times

- in line 77, 83

#### Defined variables

intrupted defined in line 74; used 4 times

- in line 78-82(2), 88-90(2)

noting defined in line 43; used 6 times

- in line 46-63(6)

#### Defined macros

Note defined in line 13; used 2 times

- in line 20, 33

Plausible defined in line 10; used 2 times

- in line 18, 27

deNote defined in line 14; used 2 times

- in line 31, 39

Last modified: 1985-08-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 692 |