Beispiel #1
0
bool
StackPush(struct Stack *s, int e)
{
    if (StackFull(s))
        return false;
    s->top++;
    s->array[s->top] = e;
    return true;
}
Beispiel #2
0
void *suser_malloc(int bytes, int which_end, GlobalLU_t *Glu)
{
    void *buf;
    
    if ( StackFull(bytes) ) return (NULL);

    if ( which_end == HEAD ) {
	buf = (char*) Glu->stack.array + Glu->stack.top1;
	Glu->stack.top1 += bytes;
    } else {
	Glu->stack.top2 -= bytes;
	buf = (char*) Glu->stack.array + Glu->stack.top2;
    }
    
    Glu->stack.used += bytes;
    return buf;
}
Beispiel #3
0
void *duser_malloc_dist(int_t bytes, int_t which_end)
{
    void *buf;
    
    if ( StackFull(bytes) ) return (NULL);

    if ( which_end == HEAD ) {
	buf = (char*) stack.array + stack.top1;
	stack.top1 += bytes;
    } else {
	stack.top2 -= bytes;
	buf = (char*) stack.array + stack.top2;
    }
    
    stack.used += bytes;
    return buf;
}
Beispiel #4
0
int main(void) {
Stack s;
StackEntry e;

CreateStack(&s); //for intializing the stack

if (!StackFull(&s))
    Push (e, &s);

if (!StackEmpty(&s))
	Pop (&e, &s);

if (!StackEmpty(&s))
	StackTop (&e, &s);

x = StackSize (&s);

ClearStack (&s);

return 0;

}
void push(char item,stack *s)
{if (StackFull(s))
  printf("Stack is Full\n");
 else s->entry[s->top++]=item;
}