~ubuntu-branches/ubuntu/hardy/silo/hardy-updates

« back to all changes in this revision

Viewing changes to common/malloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2007-10-25 09:28:08 UTC
  • mfrom: (15.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071025092808-1yhj12t7s4zqsfu5
Tags: 1.4.13a+git20070930-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build with -fno-stack-protector.
  - Change silo.postinst to automatically update the boot block without
    invoking siloconfig and keep asking questions on upgrades.
  - Convert silo.conf to use /dev/disk/by-uuid.
  - Ubuntu maintainer foobar.
  - Fix debian/rules call to dh_installdocs.
  - Drop the requirement of gcc-4.1 and start using default gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Dump memory allocation routines
 
2
   
 
3
   Copyright (C) 1996 Maurizio Plaza
 
4
                 1996 Jakub Jelinek
 
5
   
 
6
   This program is free software; you can redistribute it and/or modify
 
7
   it under the terms of the GNU General Public License as published by
 
8
   the Free Software Foundation; either version 2 of the License, or
 
9
   (at your option) any later version.
 
10
   
 
11
   This program is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
   GNU General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU General Public License
 
17
   along with this program; if not, write to the Free Software
 
18
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
19
   USA.  */
 
20
 
 
21
#ifndef MALLOC_BASE
 
22
extern unsigned long _start;
 
23
static char *malloc_ptr = ((char *)&_start) + 0x30000;
 
24
#else
 
25
static char *malloc_ptr = (char *) MALLOC_BASE;
 
26
#endif
 
27
 
 
28
static char *last_alloc = 0;
 
29
 
 
30
void *malloc (int size)
 
31
{
 
32
    char *caddr;
 
33
 
 
34
    caddr = malloc_ptr;
 
35
    malloc_ptr += size;
 
36
    last_alloc = caddr;
 
37
    malloc_ptr = (char *) ((((unsigned long) malloc_ptr) + 7) & (~7));
 
38
    return caddr;
 
39
}
 
40
 
 
41
void free (void *m)
 
42
{
 
43
    if (m == last_alloc)
 
44
        malloc_ptr = last_alloc;
 
45
}
 
46
 
 
47
void mark (void **ptr)
 
48
{
 
49
    *ptr = (void *) malloc_ptr;
 
50
}
 
51
 
 
52
void release (void *ptr)
 
53
{
 
54
    malloc_ptr = (char *) ptr;
 
55
}