File: sys.c

package info (click to toggle)
wmf 1.0.5-7
  • links: PTS
  • area: main
  • in suites: buster, sid, stretch
  • size: 412 kB
  • ctags: 337
  • sloc: ansic: 5,405; makefile: 53; sh: 19
file content (63 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*************************************************************
 * WebMailFolder                                             *
 * COPYRIGHT 1998 by Norbert Kuemin <norbert.kuemin@gmx.net> *
 *************************************************************/
   
#define SYS_FILE
#include "wmf.h"

#ifndef DMALLOC
char *newchar(int size) {
    char *tmpstr;
    
    if ((config.DebugLevel != WMF_NOVALUE) && (config.DebugLevel & 8))
	printf("....newchar(%d)\n",size);
    if (size <= 0) {
	printf("ERROR: trying to allocate %d bytes of memory\n",size);
	size = 1;
    }
    tmpstr = (char *) malloc(size);
    if (tmpstr == NULL) {
	fprintf(stderr,"* not enought memory to allocate another %d bytes *\n",size);
	exit(1);
    }
#ifdef DEBUG
    Debug.StrAlloc++;
#endif
    return tmpstr;
}

char *dupchar(char *string) {
    char *tmpstr;
    
    if ((config.DebugLevel != WMF_NOVALUE) && (config.DebugLevel & 8))
	printf("....dupchar(%s)\n",string);
    if (string == NULL) return NULL;
    tmpstr = (char *) strdup(string);
    if (tmpstr == NULL) {
	fprintf(stderr,"* not enought memory to allocate another %d bytes *\n",strlen(string));
	exit(1);
    }
#ifdef DEBUG
    Debug.StrAlloc++;
#endif
    return tmpstr;
}


void freechar(char *string) {

    if ((config.DebugLevel != WMF_NOVALUE) && (config.DebugLevel & 8))
	printf("....freechar(%s)\n",string);
#ifdef DEBUG
    Debug.StrDeAlloc++;
#endif
    if (string == NULL) return;
    free(string);
}
#endif

int isoctal(char number) {
    if ((number >= '0') && (number <= '9')) return TRUE;
    return FALSE;
}