Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes. + Change function definitions to ANSI C style. + Convert to sed scripts some shell scripts for better portability. + Reduce usage of em_path.h
This commit is contained in:
parent
4555c1c8cf
commit
0f75cc09ad
29
modules/src/alloc/CMakeLists.txt
Normal file
29
modules/src/alloc/CMakeLists.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
cmake_minimum_required (VERSION 3.0)
|
||||
project (alloc)
|
||||
|
||||
set(SRC
|
||||
botch.c
|
||||
clear.c
|
||||
Malloc.c
|
||||
No_Mem.c
|
||||
Realloc.c
|
||||
Salloc.c
|
||||
Srealloc.c
|
||||
std_alloc.c
|
||||
st_alloc.c
|
||||
alloc.h
|
||||
)
|
||||
|
||||
|
||||
add_library(${PROJECT_NAME} ${SRC})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "alloc.h")
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/alloc.3 DESTINATION man OPTIONAL)
|
||||
|
|
@ -17,9 +17,7 @@ extern char *malloc();
|
|||
#endif
|
||||
#include "alloc.h"
|
||||
|
||||
char *
|
||||
Malloc(sz)
|
||||
unsigned int sz;
|
||||
char *Malloc(unsigned int sz)
|
||||
{
|
||||
register char *res = malloc(sz);
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include <system.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "alloc.h"
|
||||
|
||||
void
|
||||
No_Mem()
|
||||
void No_Mem(void)
|
||||
{
|
||||
sys_write(STDERR, "Out of memory\n", 14);
|
||||
sys_stop(S_EXIT);
|
||||
fprintf(stderr,"Out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -19,10 +19,7 @@ extern char *realloc();
|
|||
|
||||
#include "alloc.h"
|
||||
|
||||
char *
|
||||
Realloc(ptr, sz)
|
||||
char ptr[];
|
||||
unsigned int sz;
|
||||
char *Realloc(char ptr[], unsigned int sz)
|
||||
{
|
||||
register char *mptr;
|
||||
|
||||
|
|
|
@ -19,10 +19,7 @@ extern char *malloc();
|
|||
|
||||
#include "alloc.h"
|
||||
|
||||
char *
|
||||
Salloc(str, sz)
|
||||
register char *str;
|
||||
register unsigned int sz;
|
||||
char *Salloc(register char *str, register unsigned int sz)
|
||||
{
|
||||
/* Salloc() is not a primitive function: it just allocates a
|
||||
piece of storage and copies a given string into it.
|
||||
|
|
|
@ -12,10 +12,7 @@
|
|||
|
||||
#include "alloc.h"
|
||||
|
||||
char *
|
||||
Srealloc(str, sz)
|
||||
char str[];
|
||||
unsigned int sz;
|
||||
char *Srealloc(char str[], unsigned int sz)
|
||||
{
|
||||
return Realloc(str, sz);
|
||||
}
|
||||
|
|
|
@ -5,44 +5,19 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc
|
|||
.SH SYNOPSIS
|
||||
.B #include <alloc.h>
|
||||
.PP
|
||||
.B char *Malloc(size)
|
||||
.br
|
||||
.B unsigned int size;
|
||||
.B char *Malloc(unsigned int size)
|
||||
.PP
|
||||
.B char *Salloc(str, size)
|
||||
.br
|
||||
.B char *str;
|
||||
.B unsigned int size;
|
||||
.B char *Salloc(char *str, unsigned int size)
|
||||
.PP
|
||||
.B char *Realloc(ptr, size)
|
||||
.B char *buf;
|
||||
.B unsigned int size;
|
||||
.B char *Realloc(char *buf, unsigned int size)
|
||||
.PP
|
||||
.B char *Srealloc(str, size)
|
||||
.br
|
||||
.B char *str;
|
||||
.br
|
||||
.B unsigned int size;
|
||||
.B char *Srealloc(char *str, unsigned int size)
|
||||
.PP
|
||||
.B char *st_alloc(phead, size, count)
|
||||
.br
|
||||
.B char **phead;
|
||||
.br
|
||||
.B unsigned int size;
|
||||
.B char *st_alloc(char **phead, unsigned int size, int count)
|
||||
.PP
|
||||
.B st_free(ptr, phead, size)
|
||||
.br
|
||||
.B char *ptr;
|
||||
.br
|
||||
.B char **phead;
|
||||
.br
|
||||
.B unsigned int size;
|
||||
.B st_free(char *ptr, char **phead, unsigned int size)
|
||||
.PP
|
||||
.B void clear(ptr, size)
|
||||
.br
|
||||
.B char *ptr;
|
||||
.br
|
||||
.B unsigned int size;
|
||||
.B void clear(char *ptr, unsigned int size)
|
||||
.PP
|
||||
.void No_Mem()
|
||||
.PP
|
||||
|
|
|
@ -9,10 +9,7 @@
|
|||
|
||||
#include "alloc.h"
|
||||
|
||||
void
|
||||
botch(ptr, n)
|
||||
register char *ptr;
|
||||
register unsigned int n;
|
||||
void botch(register char *ptr, register unsigned int n)
|
||||
{
|
||||
while (n >= sizeof (long)) {
|
||||
/* high-speed botch loop */
|
||||
|
|
|
@ -10,10 +10,7 @@
|
|||
|
||||
/* instead of Calloc: */
|
||||
|
||||
void
|
||||
clear(ptr, n)
|
||||
register char *ptr;
|
||||
register unsigned int n;
|
||||
void clear(register char *ptr, register unsigned int n)
|
||||
{
|
||||
register long *q = (long *) ptr;
|
||||
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
#include <stdlib.h>
|
||||
#else
|
||||
extern char *malloc();
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "alloc.h"
|
||||
|
||||
char *
|
||||
st_alloc(phead, size, count)
|
||||
char **phead;
|
||||
register unsigned int size;
|
||||
char *st_alloc(char **phead, register unsigned int size, int count)
|
||||
{
|
||||
register char *p;
|
||||
register char *p = NULL;
|
||||
register long *q;
|
||||
char *retval;
|
||||
|
||||
|
@ -29,7 +29,7 @@ st_alloc(phead, size, count)
|
|||
while (count >= 1 && (p = malloc(size * count)) == 0) {
|
||||
count >>= 1;
|
||||
}
|
||||
if (p == 0) {
|
||||
if (p == NULL) {
|
||||
No_Mem();
|
||||
}
|
||||
((_PALLOC_) p)->_A_next = 0;
|
||||
|
|
|
@ -17,11 +17,7 @@ extern char *malloc();
|
|||
|
||||
#include "alloc.h"
|
||||
|
||||
char *
|
||||
std_alloc(phead, size, count, pcnt)
|
||||
char **phead;
|
||||
register unsigned int size;
|
||||
int *pcnt;
|
||||
char *std_alloc(char **phead, register unsigned int size, int count, int *pcnt)
|
||||
{
|
||||
register char *p;
|
||||
register long *q;
|
||||
|
|
Loading…
Reference in a new issue