~ubuntu-branches/debian/jessie/arb/jessie

« back to all changes in this revision

Viewing changes to ISLAND_HOPPING/mem.cxx

  • Committer: Package Import Robot
  • Author(s): Elmar Pruesse, Andreas Tille, Elmar Pruesse
  • Date: 2014-09-02 15:15:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140902151506-jihq58b3iz342wif
Tags: 6.0.2-1
[ Andreas Tille ]
* New upstream version
  Closes: #741890
* debian/upstream -> debian/upstream/metadata
* debian/control:
   - Build-Depends: added libglib2.0-dev
   - Depends: added mafft, mrbayes
* debian/rules
   - Add explicite --remove-section=.comment option to manual strip call
* cme fix dpkg-control
* arb-common.dirs: Do not create unneeded lintian dir
* Add turkish debconf translation (thanks for the patch to Mert Dirik
  <mertdirik@gmail.com>)
  Closes: #757497

[ Elmar Pruesse ]
* patches removed:
   - 10_config.makefiles.patch,
     80_no_GL.patch
       removed in favor of creating file from config.makefile.template via 
       sed in debian/control
   - 20_Makefile_main.patch
       merged upstream
   - 21_Makefiles.patch
       no longer needed
   - 30_tmpfile_CVE-2008-5378.patch: 
       merged upstream
   - 50_fix_gcc-4.8.patch:
       merged upstream
   - 40_add_libGLU.patch:
       libGLU not needed for arb_ntree)
   - 60_use_debian_packaged_raxml.patch:
       merged upstream
   - 70_hardening.patch
       merged upstream
   - 72_add_math_lib_to_linker.patch
       does not appear to be needed
* patches added:
   - 10_upstream_r12793__show_db_load_progress:
       backported patch showing progress while ARB is loading a database
       (needed as indicator/splash screen while ARB is launching)
   - 20_upstream_r12794__socket_permissions:
       backported security fix
   - 30_upstream_r12814__desktop_keywords:
       backported add keywords to desktop (fixes lintian warning)
   - 40_upstream_r12815__lintian_spelling:
       backported fix for lintian reported spelling errors
   - 50_private_nameservers
       change configuration to put nameservers into users home dirs
       (avoids need for shared writeable directory)
   - 60_use_debian_phyml
       use phyml from debian package for both interfaces in ARB
* debian/rules:
   - create config.makefile from override_dh_configure target
   - use "make tarfile" in override_dh_install
   - remove extra cleaning not needed for ARB 6
   - use "dh_install --list-missing" to avoid missing files
   - added override_dh_fixperms target
* debian/control:
   - added libarb-dev package
   - Depends: added phyml, xdg-utils
   - Suggests: removed phyml
   - fix lintian duplicate-short-description (new descriptions)
* debian/*.install:
   - "unrolled" confusing globbing to select files
   - pick files from debian/tmp
   - moved all config files to /etc/arb
* debian/arb-common.templates: updated
* scripts:
   - removed arb-add-pt-server
   - launch-wrapper: 
     - only add demo.arb to newly created $ARBUSERDATA
     - pass commandline arguments through bin/arb wrapper
   - preinst: removing old PT server index files on upgrade from 5.5*
   - postinst: set setgid on shared PT dir
* rewrote arb.1 manfile
* added file icon for ARB databases
* using upstream arb_tcp.dat

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// =============================================================
 
2
/*                                                               */
 
3
//   File      : mem.c
 
4
//   Purpose   :
 
5
/*                                                               */
 
6
//   Institute of Microbiology (Technical University Munich)
 
7
//   http://www.arb-home.de/
 
8
/*                                                               */
 
9
// =============================================================
 
10
 
 
11
#include "mem.h"
 
12
#include <stdio.h>
 
13
#include <attributes.h>
 
14
 
 
15
#define MINSIZE 72 // >= sizeof(Node)
 
16
 
 
17
static void *M=NULL,*D=NULL;
 
18
static size_t A=0;
 
19
 
 
20
// ==========================================================================
 
21
 
 
22
static void clearUp(void) { void *v;
 
23
    while(D) {v=D; D=((void **)v)[0]; free(v);}
 
24
    while(M) {v=M; M=((void **)v)[0]; free(v);}
 
25
}
 
26
 
 
27
// ==========================================================================
 
28
 
 
29
__ATTR__NORETURN static void outOfMemory(void) {
 
30
    fprintf(stdout,"\n!!! Out of Memory\n");
 
31
    clearUp();
 
32
    exit(EXIT_FAILURE);
 
33
}
 
34
 
 
35
// ==========================================================================
 
36
 
 
37
 
 
38
void *newBlock(size_t s) {
 
39
    void *v; size_t S;
 
40
 
 
41
    if(D&&s<=MINSIZE) {
 
42
        v=D; D=((void **)v)[0];
 
43
    }
 
44
    else {
 
45
        S=((s<=MINSIZE)?MINSIZE:s)+3*sizeof(void *);
 
46
        v=malloc(S);
 
47
        if(v==NULL) outOfMemory();
 
48
        A+=S;
 
49
    }
 
50
 
 
51
    if(M) ((void **)M)[1]=v;
 
52
    ((void **)v)[0]=M; M=v;
 
53
    ((void **)v)[1]=NULL;
 
54
    ((void **)v)[2]=(void *)s;
 
55
 
 
56
 
 
57
    return(((void **)v)+3);
 
58
}
 
59
 
 
60
//........
 
61
 
 
62
void freeBlock_(void **vv) {
 
63
    void *v; size_t s;
 
64
 
 
65
    v=(void *)(((void **)(*vv))-3);
 
66
 
 
67
    if(((void **)v)[0]) ((void ***)v)[0][1]=((void **)v)[1];
 
68
    if(((void **)v)[1]) ((void ***)v)[1][0]=((void **)v)[0];
 
69
    else                M=((void **)v)[0];
 
70
 
 
71
    s=(size_t)(((void **)v)[2]);
 
72
 
 
73
    if(s<=MINSIZE) {
 
74
        ((void **)v)[0]=D; D=v;
 
75
    }
 
76
    else {
 
77
        A-=s+3*sizeof(void *);
 
78
        free(v);
 
79
    }
 
80
 
 
81
    *vv=NULL;
 
82
}
 
83
 
 
84
// ==========================================================================
 
85
 
 
86
void **newMatrix(size_t nrow,size_t ncol,size_t s) {
 
87
    size_t i,p;
 
88
    void **m;
 
89
 
 
90
    m=(void **)newBlock(nrow*sizeof(void *));
 
91
 
 
92
    p=ncol*s; for(i=0;i<nrow;i++) m[i]=newBlock(p);
 
93
 
 
94
    return(m);
 
95
}
 
96
 
 
97
//........
 
98
 
 
99
void freeMatrix_(void ***mm) {
 
100
    void **m; size_t i,rows;
 
101
 
 
102
    m=*mm;
 
103
    rows=((size_t)m[-1])/sizeof(void *);
 
104
    for(i=0;i<rows;i++) freeBlock(m+i);
 
105
    freeBlock((void **)mm);
 
106
 
 
107
}