• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

シェルスクリプト言語xyzshのソースコード。


Commit MetaInfo

修订版b5b4e6f501193bda7c280b7c6ee0736e6a7ea1ee (tree)
时间2013-01-17 22:01:53
作者ab25cq <ab25cq@gmai...>
Commiterab25cq

Log Message

1.3.1

更改概述

差异

--- a/configure
+++ b/configure
@@ -3024,7 +3024,7 @@ fi
30243024 #####################################################################
30253025 # check operating systems
30263026 #####################################################################
3027-SO_VERSION=1.5.8
3027+SO_VERSION=1.7.0
30283028
30293029 { $as_echo "$as_me:${as_lineno-$LINENO}: checking Operating System" >&5
30303030 $as_echo_n "checking Operating System... " >&6; }
--- a/src/memchecker.c
+++ /dev/null
@@ -1,175 +0,0 @@
1-#include "config.h"
2-#include "xyzsh/xyzsh.h"
3-#include <string.h>
4-#include <stdio.h>
5-#include <signal.h>
6-
7-memchecker_it* memchecker_it_new(void* key, int item, memchecker_it* coll_it, memchecker_it* next_it, sObject* memchecker)
8-{
9- memchecker_it* it = (memchecker_it*)MALLOC(sizeof(memchecker_it));
10-
11- it->mKey = key;
12-
13- it->mItem = item;
14- it->mCollisionIt = coll_it;
15-
16- it->mNextIt = next_it;
17-
18- return it;
19-}
20-
21-void memchecker_it_release(memchecker_it* it, sObject* memchecker)
22-{
23- FREE(it);
24-}
25-
26-sObject* memchecker_new_from_stack(int size)
27-{
28- sObject* self = stack_get_free_object(T_MEMCHECKER);
29-
30- SMEMCHECKER(self).mTableSize = size;
31- SMEMCHECKER(self).mTable = (memchecker_it**)MALLOC(sizeof(memchecker_it*) * size);
32- memset(SMEMCHECKER(self).mTable, 0, sizeof(memchecker_it*)*size);
33-
34- SMEMCHECKER(self).mEntryIt = NULL;
35-
36- SMEMCHECKER(self).mCounter = 0;
37-
38- return self;
39-}
40-
41-void memchecker_delete_stack(sObject* self)
42-{
43- memchecker_it* it = SMEMCHECKER(self).mEntryIt;
44-
45- while(it) {
46- memchecker_it* next_it = it->mNextIt;
47- memchecker_it_release(it, self);
48- it = next_it;
49- }
50-
51- FREE(SMEMCHECKER(self).mTable);
52-}
53-
54-static unsigned int get_hash_value(sObject* self, void* key)
55-{
56- return ((unsigned long)key) % SMEMCHECKER(self).mTableSize;
57-}
58-
59-static void resize(sObject* self)
60-{
61- const int table_size = SMEMCHECKER(self).mTableSize;
62-
63- SMEMCHECKER(self).mTableSize *= 5;
64- FREE(SMEMCHECKER(self).mTable);
65- SMEMCHECKER(self).mTable = (memchecker_it**)MALLOC(sizeof(memchecker_it*) * SMEMCHECKER(self).mTableSize);
66- memset(SMEMCHECKER(self).mTable, 0, sizeof(memchecker_it*)*SMEMCHECKER(self).mTableSize);
67-
68- memchecker_it* it = SMEMCHECKER(self).mEntryIt;
69- while(it) {
70- unsigned int hash_key = get_hash_value(self, it->mKey);
71-
72- it->mCollisionIt = SMEMCHECKER(self).mTable[hash_key];
73-
74- SMEMCHECKER(self).mTable[hash_key] = it;
75-
76- it = it->mNextIt;
77- }
78-}
79-
80-void memchecker_put(sObject* self, void* key, int item)
81-{
82- if(SMEMCHECKER(self).mCounter >= SMEMCHECKER(self).mTableSize) {
83- resize(self);
84- }
85-
86- unsigned int hash_key = get_hash_value(self, key);
87-
88- memchecker_it* it = SMEMCHECKER(self).mTable[ hash_key ];
89-//printf("counter %d table size %d hash_key %u\n", SMEMCHECKER(self).mCounter, SMEMCHECKER(self).mTableSize, hash_key);
90- while(it) {
91- if(key == it->mKey) {
92- it->mItem = item;
93- return;
94- }
95- it = it->mCollisionIt;
96- }
97-
98- memchecker_it* new_it
99- = memchecker_it_new(key, item, SMEMCHECKER(self).mTable[hash_key], SMEMCHECKER(self).mEntryIt, self);
100-
101- SMEMCHECKER(self).mTable[hash_key] = new_it;
102- SMEMCHECKER(self).mEntryIt = new_it;
103- SMEMCHECKER(self).mCounter++;
104-}
105-
106-static void erase_from_list(sObject* self, memchecker_it* rit)
107-{
108- if(rit == SMEMCHECKER(self).mEntryIt) {
109- SMEMCHECKER(self).mEntryIt = rit->mNextIt;
110- }
111- else {
112- memchecker_it* it = SMEMCHECKER(self).mEntryIt;
113-
114- while(it->mNextIt) {
115- if(it->mNextIt == rit) {
116- it->mNextIt = it->mNextIt->mNextIt;
117- break;
118- }
119-
120- it = it->mNextIt;
121- }
122- }
123-}
124-
125-BOOL memchecker_erase(sObject* self, void* key)
126-{
127- const unsigned int hash_value = get_hash_value(self, key);
128- memchecker_it* it = SMEMCHECKER(self).mTable[hash_value];
129-
130- if(it == NULL)
131- ;
132- else if(it->mKey == key) {
133- memchecker_it* it2 = SMEMCHECKER(self).mEntryIt;
134- SMEMCHECKER(self).mTable[ hash_value ] = it->mCollisionIt;
135-
136- erase_from_list(self, it);
137-
138- memchecker_it_release(it, self);
139-
140- SMEMCHECKER(self).mCounter--;
141-
142- return TRUE;
143- }
144- else {
145- memchecker_it* prev_it = it;
146- it = it->mCollisionIt;
147- while(it) {
148- if(it->mKey == key) {
149- prev_it->mCollisionIt = it->mCollisionIt;
150- erase_from_list(self, it);
151- memchecker_it_release(it, self);
152- SMEMCHECKER(self).mCounter--;
153-
154- return TRUE;
155- }
156-
157- prev_it = it;
158- it = it->mCollisionIt;
159- }
160- }
161-
162- return FALSE;
163-}
164-
165-int memchecker_item(sObject* self, void* key)
166-{
167- memchecker_it* it = SMEMCHECKER(self).mTable[ get_hash_value(self, key) ];
168-
169- while(it) {
170- if(key == it->mKey) return it->mItem;
171- it = it->mCollisionIt;
172- }
173-
174- return -1;
175-}