source: git/factory/mmallocs.c @ 6c44098

spielwiese
Last change on this file since 6c44098 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/* emacs edit mode for this file is -*- C -*- */
2/* $Id$ */
3
4#define _POSIX_SOURCE 1
5
6#include <config.h>
7
8#include <stdlib.h>
9#include <stdio.h>
10
11#include "memman.h"
12#include "mmprivate.h"
13
14#ifndef MDEBUG
15
16void *
17mmAllocSpecialized( void )
18{
19    mcb result;
20
21    if ( mm_theList[mm_specIndex] == NULL )
22        return mmAllocBlock( mmGetSize( mm_specIndex ) );
23    result = mm_theList[mm_specIndex];
24    mm_theList[mm_specIndex] = (mcb)*result;
25#ifdef MM_COUNT
26    mm_bytesUsed += mmGetSize( mm_specIndex );
27#endif
28    return (void*)result;
29}
30
31void
32mmFreeSpecialized( void* adr )
33{
34    *((mcb)adr) = mm_theList[mm_specIndex];
35    mm_theList[mm_specIndex] = (mcb)adr;
36#ifdef MM_COUNT
37    mm_bytesUsed -= mmGetSize( mm_specIndex );
38#endif
39}
40
41#else /* MDEBUG */
42
43void *
44mmDBAllocSpecialized( char* fname, int lineno )
45{
46    return mmDBAllocBlock( mm_specSize, fname, lineno );
47}
48
49void
50mmDBFreeSpecialized( void* adr, char* fname, int lineno )
51{
52    mmDBFreeBlock( adr, mm_specSize, fname, lineno );
53}
54
55#endif /* MDEBUG */
56
57
58void
59mmSpecializeBlock( size_t size )
60{
61    mm_specIndex = mmGetIndex( size );
62    if (mm_specIndex<0) {
63        fprintf(stderr,"too many ring variables\nleaving Singular...");
64        exit(11);
65    }
66    mm_specSize = size;
67}
Note: See TracBrowser for help on using the repository browser.