Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37559633
en ru br
ALT Linux repos
S:0.2-alt2
5.0: 0.1-alt1
4.1: 0.1-alt1
4.0: 0.1-alt1

Group :: System/Libraries
RPM: libzmalloc

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

libzmalloc-0.1/000075500000000000000000000000001062502642200134775ustar00rootroot00000000000000libzmalloc-0.1/Makefile000064400000000000000000000015721062502642200151440ustar00rootroot00000000000000LIBRARY = libzmalloc
VERSION=0.1
MAJOR = 0

SHAREDLIB = $(LIBRARY).so
SONAME = $(SHAREDLIB).$(MAJOR)

INSTALL = install

LIBDIR = $(libdir)

CC=gcc
CFLAGS =$(FLAGS) -I../include $(RPM_OPT_FLAGS)
LINK.o = $(CC) $(LDFLAGS) $(FLAGS) $(TARGET_ARCH)

LIB_SRC = zmalloc.c

LIB_SOBJ = $(LIB_SRC:%.c=%.so)

.PHONY: all install clean

all: $(SHAREDLIB)

install: all
$(INSTALL) -pD -m755 $(SHAREDLIB) $(libdir)/$(SHAREDLIB).$(VERSION)
@ln -sf $(SHAREDLIB).$(VERSION) $(libdir)/$(SONAME)
@ln -sf $(SONAME) $(libdir)/$(SHAREDLIB)
$(INSTALL) -pD -m755 zmalloc-enable $(bindir)/zmalloc-enable
$(INSTALL) -pD -m755 zmalloc-disable $(bindir)/zmalloc-disable

clean:
$(RM) $(LIB_SOBJ) $(SHAREDLIB) $(SONAME) core *~ test

$(SHAREDLIB): $(LIB_SOBJ)
$(LINK.o) -shared -Wl,-soname,$(SONAME) $+ $(OUTPUT_OPTION)
ln -sf $(SHAREDLIB) $(SONAME)

%.so: %.c
$(CC) -c $(CPPFLAGS) -fpic $< $(OUTPUT_OPTION)
libzmalloc-0.1/test1.c000064400000000000000000000005731062502642200147100ustar00rootroot00000000000000#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define SIZE 100

print_memory(char *c,int size)
{
int i;
for(i=0;i<size;i++){
printf(" %.2x",*(c+i));
if ((i+1) % 20 == 0) puts("");
}
puts("");
}

int main(void)
{
char *l=(char*)malloc(SIZE);

if (l)
print_memory(l,SIZE);
else
puts("unable to malloc memory");

return 0;
}
libzmalloc-0.1/test2.c000064400000000000000000000010111062502642200146750ustar00rootroot00000000000000#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define SIZE 100

print_memory(char *c,int size)
{
int i;
for(i=0;i<size;i++){
printf(" %.2x",*(c+i));
if ((i+1) % 20 == 0) puts("");
}
puts("");
}


int main()
{
char *c;

c=malloc(SIZE*sizeof(char));
memset(c,0x33,SIZE*sizeof(char));
puts("old memory content:");
print_memory(c,SIZE);

free(c);
c=malloc(SIZE*sizeof(char));

puts("new memory content:");
print_memory(c,SIZE);

return 0;
}

libzmalloc-0.1/zmalloc-disable000075500000000000000000000001271062502642200164670ustar00rootroot00000000000000#!/bin/sh

sed '\,^/lib/libzmalloc.so.0.1$, d' -i /etc/ld.so.preload && /sbin/ldconfig
libzmalloc-0.1/zmalloc-enable000075500000000000000000000002371062502642200163140ustar00rootroot00000000000000#!/bin/sh

if ! grep -qs '^/lib/libzmalloc\.so\.0.1$' /etc/ld.so.preload; then
echo '/lib/libzmalloc.so.0.1' >>/etc/ld.so.preload &&
/sbin/ldconfig
fi
libzmalloc-0.1/zmalloc.c000064400000000000000000000002631062502642200153050ustar00rootroot00000000000000#define _GNU_SOURCE 1
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>

void *malloc(size_t size){
return calloc(1,size);
}

void free(void *ptr){
cfree(ptr);
}
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin