Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/**
22
 ------------
614 giacomo 23
 CVS :        $Id: free.c,v 1.2 2004-05-07 10:09:10 giacomo Exp $
2 pj 24
 
25
 File:        $File$
614 giacomo 26
 Revision:    $Revision: 1.2 $
27
 Last update: $Date: 2004-05-07 10:09:10 $
2 pj 28
 ------------
29
 
30
**/
31
 
32
/*
33
 * Copyright (C) 2000 Paolo Gai
34
 *
35
 * This program is free software; you can redistribute it and/or modify
36
 * it under the terms of the GNU General Public License as published by
37
 * the Free Software Foundation; either version 2 of the License, or
38
 * (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48
 *
49
 */
50
 
51
#include <kernel/func.h>
52
#include <sys/types.h>
53
#include <string.h>
54
#include <stdlib.h>
55
 
56
void free(void *ptr)
57
{
58
  if (ptr) {
59
    char *p = ptr;
60
    SYS_FLAGS f;
61
 
62
    f = kern_fsave();
63
    //kern_cli();
64
    p -= sizeof(size_t);
614 giacomo 65
    if (*(size_t *)p == 0) {
66
        kern_frestore(f);
67
        return;
68
    }
2 pj 69
    kern_free(p,*((size_t *)p));
70
    //kern_sti();
71
    kern_frestore(f);
72
  }
73
}