sauravdas90 / cii Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/cii
License: Other
Automatically exported from code.google.com/p/cii
License: Other
This hierarchy contains all the source code from my book "C Interfaces and Implementations: Techniques for Creating Reusable Software (Addison-Wesley Professional Computing Series, 1997, ISBN 0-201-49841-3). For installation instructions, see install.html. For a summary of the distribution's revision history see see http://code.google.com/p/cii/w/list For the history of versions before 1.2, see http://cii.googlecode.com/svn/tags/v12/history.html For more information, visit http://www.cs.princeton.edu/software/cii/. ----- David R. Hanson drh at drhanson.net / http://drh.home.dyndns.org/
From: Norman Ramsey <[email protected]>
Date: Sun, Nov 23, 2008 at 1:41 PM
chan.o should really be in $(THREADS), not in the main $(OBJS).
Without a threads package, I can't easily build a shared library for cii.
Also for some reason I was not able to get the custom.mk to work
as I expected, so I've left in a patch I used to build a shared
library on 64-bit RHEL 5. Presumably you could use something
similar to build a DLL on windows? Not sure.
Appended is a diff.
--- makefile 2008-11-23 14:33:30.623248000 -0500
+++ makefile.orig 2008-09-30 00:43:42.000000000 -0400
@@ -14,7 +14,7 @@
RM=rm -f
CUSTOM=custom.mk
EXTRAS=$(BUILDDIR)memcmp$O $(BUILDDIR)memmove$O $(BUILDDIR)strncmp$O
-THREADS=$(BUILDDIR)thread$O $(BUILDDIR)swtch$O $(BUILDDIR)chan$O
+THREADS=$(BUILDDIR)thread$O $(BUILDDIR)swtch$O
include $(CUSTOM)
B=$(BUILDDIR)
@@ -25,6 +25,7 @@
$Bassert$O \
$Batom$O \
$Bbit$O \
+ $Bchan$O \
$Bexcept$O \
$Bfmt$O \
$Blist$O \
@@ -61,9 +62,6 @@
$Blibcii$A:: $(OBJS) $(EXTRAS)
$(AR) $@ $(OBJS) $(EXTRAS); $(RANLIB) $@ || true
-$Blibcii$(SO).$(MAJORVERSION): $(OBJS) $(EXTRAS)
- $(CC) -shared -Wl,-soname,libcii.so.2 \
- -o $@ $(OBJS) $(EXTRAS)
$Bap$O: src/ap.c; $(CC) $(CFLAGS) -c -o $@ src/ap.c
$Barena$O: src/arena.c; $(CC) $(CFLAGS) -c -o $@ src/arena.c
Original issue reported on code.google.com by [email protected]
on 24 Nov 2008 at 6:58
I think there's a memory leak in the Arena code.
Consider a scenario where:
* You create and release 3 arenas, each with a chunk of say 20KB of memory.
* You create a new arena, using one of those chunks; there are 2 chunks
left on the free list.
* You attempt to allocate a chunk of size 100KB.
If I read the code correctly, the loop in Arena_alloc() - p94 of the third
printing - invokes <get a new chunk 95>. Each time that is called, it
removes a chunk from the freelist, finds that it is not big enough, and
discards it, rather than restoring it to the freelist or releasing it.
--
Jonathan Leffler <[email protected]>
Original issue reported on code.google.com by [email protected]
on 29 Sep 2008 at 7:50
What steps will reproduce the problem?
In CII's chapter 9, Set_union(s,NULL) clones a set, but the cloned set's size
is smaller.
Here is test code:
Set_T s,t;
s = Set_new(1024,NULL,NULL);
t = Set_union(s,NULL);
printf("s:%d, t:%d\n", s->size,t->size);
output is:
s:1021, t:509
The problem seems related to Set_new's implementation:
static int primes[] = { 509, 509, 1021, 2053, 4093,
8191, 16381, 32771, 65521, INT_MAX };
assert(hint >= 0);
for (i = 1; primes[i] < hint; i++)
;
When giving it a hint, it searches the primes table and use the greatest one less than hint.
If the hint happens to be the number in primes, a much less value will be used.
What is the expected output? What do you see instead?
When clone a set, it's member size should be the same.
What version of the product are you using? On what operating system?
N/A
Please provide any additional information below.
N/A
Original issue reported on code.google.com by [email protected]
on 27 Jun 2012 at 12:46
In Ch20, 20.2.1, Sorting concurrently, partition's implementation might access
the invalid memory.
1 int partition(int a[], int i, int j) {
2 int v, k, t;
3 j++;
4 k = i;
5 v = a[k];
6 while (i < j) {
7 i++; while (a[i] < v && i < j) i++;
8 j--; while (a[j] > v) j--;
9 if (i < j) { t = a[i]; a[i] = a[j]; a[j] = t; }
10 }
11 t = a[k]; a[k] = a[j]; a[j] = t;
12 return j;
13 }
For example:
int a[5] = {5,4,3,2,1};
partition(a,0,4);
line 3 increments j to 5, line 7's a[i] < v will access a[5], which is out of
the upper boundary of array.
Maybe, line 7 should be changed as
i++; while (i < j && a[i] < v) i++;
Original issue reported on code.google.com by [email protected]
on 9 Jul 2012 at 2:45
I'm trying to use the memchk.c library to check some of my code, but I was
getting an assertion error on FREE'ing because this test was failing:
((unsigned long)ptr) % (sizeof (union align)) != 0
Upon review, it looks like it is a result of malloc not returning a pointer
that is aligned according to `sizeof(union align)`. For example, I added the
following check to the `dalloc` function:
size_t alignment = sizeof(union align);
assert((alignment & (alignment - 1)) == 0); // make sure alignment is a power of 2
void *nptr = (void *)(((unsigned long)ptr + (alignment-1)) & ~ (size_t)(alignment-1));
assert(ptr == nptr);
And my code would fail, but I would expect that nptr should equal ptr? If the
code was modified to change:
avail->ptr = ptr;
to:
avail->ptr = (void *)(((unsigned long)ptr + (alignment-1)) & ~ (size_t)(alignment-1));
I don't think it would have any affect other than to assure that the memory is
aligned along the boundaries we believe it is.
Original issue reported on code.google.com by [email protected]
on 26 Jul 2011 at 4:22
1, Optional return statement.
2, NDEBUG defined or not.
Original issue reported on code.google.com by [email protected]
on 15 Oct 2012 at 9:51
Attachments:
have you posted the solutions to the examples(at the end of each chapter)
to somewhere that we can reach?
Thanks
Original issue reported on code.google.com by [email protected]
on 2 Jun 2012 at 10:12
Are any particular reason to use pointer to pointers for list manipulation?
For example, in the List interface
T List_append(T list, T tail){
T *p = &list;
while (*p)
p = &(*p)->rest;
*p = tail;
return list;
}
Writing this function using just pointers like:
T List_append(T list, T tail){
T p = list;
assert(p)
while (p->rest)
p = p->rest;
p->rest = tail;
return list;
}
Implementing those functions using pointer to pointers is more efficient or you
just choose that for showing an idiom.
Thanks
Original issue reported on code.google.com by [email protected]
on 31 May 2012 at 7:00
Hi,
Is the Except lib tread safe ?
I have a multithreaded app, i really like your small Except lib but is it safe ?
Thanks,
Alex
Original issue reported on code.google.com by ealexs
on 14 Feb 2011 at 10:21
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 31 May 2012 at 12:49
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.