source: git/factory/mmallocs.c @ 84250a6

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