Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,977 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*test | ||
*.o | ||
libds.a | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Copyright (c) 2011 Zhehao Mao | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CFLAGS=-O2 -Wall | ||
LDFLAGS=-L. -lds | ||
HEADERS=list.h vector.h hashmap.h strutils.h heap.h tree.h | ||
OBJS=list.o vector.o hashmap.o strutils.o heap.o tree.o | ||
PREFIX=/usr/local | ||
CC=gcc | ||
|
||
libds.a: $(OBJS) | ||
ar rcs libds.a $(OBJS) | ||
|
||
test: listtest vectest maptest strutiltest heaptest treetest | ||
|
||
ds.h: $(HEADERS) | ||
cat $(HEADERS) | sed -e 's/#include "vector.h"//' > ds.h | ||
|
||
%test: %test.c libds.a | ||
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ | ||
|
||
%.o: %.c %.h | ||
$(CC) $(CFLAGS) -c $< | ||
|
||
clean: | ||
rm -f *test *.o *.a | ||
|
||
install: ds.h libds.a | ||
mkdir -p $(PREFIX)/lib | ||
cp libds.a $(PREFIX)/lib | ||
mkdir -p $(PREFIX)/include | ||
cp ds.h $(PREFIX)/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
libds - Simple, Memory-Safe Data Structures in C | ||
======================================================================== | ||
|
||
This is a collection of C implementations of common data structures that | ||
I use in many of my C projects. It includes the following procedures and | ||
data structures. | ||
|
||
Hashmap | ||
Vector (auto-expanding array) | ||
Linked List | ||
String Buffer (auto-expanding, length-recording string) | ||
|
||
Installation Instructions: | ||
|
||
Running make with no arguments will generate a shared library named libds.a. | ||
You can then copy that library, as well as all header files, into your | ||
project directory. If you do not wish to use separate header files, you may | ||
generate a single header file called ds.h by running make ds.h. | ||
|
||
You can link your applications to the static library like so. | ||
|
||
gcc -static main.c -L. -lds -o main | ||
|
||
Assuming that main.c is your program and libds.a has been copied into the | ||
same directory. | ||
|
||
Documentation on how to use the various functions and datastructures can be | ||
found in the header files. | ||
|
||
License: | ||
|
||
libds is distributed under the MIT License, the full text of which is | ||
reproduced in LICENSE. |
Oops, something went wrong.