release comprehension and optimize zlib stack usage

This commit is contained in:
Lyon 2023-07-27 18:01:18 +08:00
parent 94879d166f
commit 9178ba9789
6 changed files with 23 additions and 13 deletions

View File

@ -22,7 +22,7 @@
*/
#include "fastlz.h"
#include "PikaObj.h"
#include <stdint.h>
#pragma GCC diagnostic push
@ -232,7 +232,8 @@ int fastlz1_compress(const void* input, int length, void* output) {
const uint8_t* ip_limit = ip + length - 12 - 1;
uint8_t* op = (uint8_t*)output;
uint32_t htab[HASH_SIZE];
// uint32_t htab[HASH_SIZE];
uint32_t* htab = (uint32_t*)pikaMalloc(sizeof(uint32_t) * HASH_SIZE);
uint32_t seq, hash;
/* initializes hash table */
@ -289,6 +290,7 @@ int fastlz1_compress(const void* input, int length, void* output) {
uint32_t copy = (uint8_t*)input + length - anchor;
op = flz_literals(copy, anchor, op);
pikaFree(htab, sizeof(uint32_t) * HASH_SIZE);
return op - (uint8_t*)output;
}
@ -377,7 +379,8 @@ int fastlz2_compress(const void* input, int length, void* output) {
const uint8_t* ip_limit = ip + length - 12 - 1;
uint8_t* op = (uint8_t*)output;
uint32_t htab[HASH_SIZE];
// uint32_t htab[HASH_SIZE];
uint32_t* htab = (uint32_t*)pikaMalloc(sizeof(uint32_t) * HASH_SIZE);
uint32_t seq, hash;
/* initializes hash table */
@ -446,6 +449,7 @@ int fastlz2_compress(const void* input, int length, void* output) {
/* marker for fastlz2 */
*(uint8_t*)output |= (1 << 5);
pikaFree(htab, sizeof(uint32_t) * HASH_SIZE);
return op - (uint8_t*)output;
}

View File

@ -22,7 +22,7 @@
*/
#include "fastlz.h"
#include "PikaObj.h"
#include <stdint.h>
#pragma GCC diagnostic push
@ -232,7 +232,8 @@ int fastlz1_compress(const void* input, int length, void* output) {
const uint8_t* ip_limit = ip + length - 12 - 1;
uint8_t* op = (uint8_t*)output;
uint32_t htab[HASH_SIZE];
// uint32_t htab[HASH_SIZE];
uint32_t* htab = (uint32_t*)pikaMalloc(sizeof(uint32_t) * HASH_SIZE);
uint32_t seq, hash;
/* initializes hash table */
@ -289,6 +290,7 @@ int fastlz1_compress(const void* input, int length, void* output) {
uint32_t copy = (uint8_t*)input + length - anchor;
op = flz_literals(copy, anchor, op);
pikaFree(htab, sizeof(uint32_t) * HASH_SIZE);
return op - (uint8_t*)output;
}
@ -377,7 +379,8 @@ int fastlz2_compress(const void* input, int length, void* output) {
const uint8_t* ip_limit = ip + length - 12 - 1;
uint8_t* op = (uint8_t*)output;
uint32_t htab[HASH_SIZE];
// uint32_t htab[HASH_SIZE];
uint32_t* htab = (uint32_t*)pikaMalloc(sizeof(uint32_t) * HASH_SIZE);
uint32_t seq, hash;
/* initializes hash table */
@ -446,6 +449,7 @@ int fastlz2_compress(const void* input, int length, void* output) {
/* marker for fastlz2 */
*(uint8_t*)output |= (1 << 5);
pikaFree(htab, sizeof(uint32_t) * HASH_SIZE);
return op - (uint8_t*)output;
}

View File

@ -5,13 +5,13 @@ def test_socket_GET():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 获取服务器的IP地址
server_ip = socket.gethostbyname('baidu.com')
# server_ip = socket.gethostbyname('baidu.com')
server_port = 80
# 连接到服务器
s.connect((server_ip, server_port))
s.connect(('pikapython.com', server_port))
# 创建HTTP GET请求
request = 'GET / HTTP/1.1\r\nHost: baidu.com\r\n\r\n'
request = 'GET / HTTP/1.1\r\nHost: pikascript.com\r\n\r\n'
# print('request:', request)
s.send(request.encode())
@ -29,7 +29,9 @@ def test_socket_GET():
return response
for i in range(10):
res = 'HTTP/1.1 200 OK' in test_socket_GET()
response = test_socket_GET()
res = 'HTTP/1.1' in response
if res == True:
break
print('test_socket_GET() failed, retrying...')
print('response', response)

View File

@ -2,4 +2,4 @@
#define PIKA_VERSION_MINOR 12
#define PIKA_VERSION_MICRO 4
#define PIKA_EDIT_TIME "2023/07/26 17:08:07"
#define PIKA_EDIT_TIME "2023/07/26 22:10:04"

View File

@ -145,7 +145,7 @@ static int _do_main(int argc, char **argv) {
char *file_out_name = strsAppend(&buffs, file_name_no_ext, ".md");
printf("file_out_name: %s\r\n", file_out_name);
char *file_out_path = strsPathJoin(&buffs, file_folder, file_out_name);
Parser *parser = New_parser();
Parser *parser = parser_create();
printf("generating doc %s: %s\r\n", file_path, file_out_path);
parser_file2DocFile(parser, file_path, file_out_path);
strsDeinit(&buffs);
@ -160,7 +160,7 @@ static int _do_main(int argc, char **argv) {
Args buffs = {0};
char *file_path = argv[2];
char *file_out_path = argv[4];
Parser *parser = New_parser();
Parser *parser = parser_create();
printf("generating doc %s: %s\r\n", file_path, file_out_path);
parser_file2DocFile(parser, file_path, file_out_path);
strsDeinit(&buffs);