From 49cfd34cd6dc546bbcd7cd945c3559836a105cf3 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Thu, 16 Jun 2011 13:39:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=D1=8B=20zalloc=5Fext?= =?UTF-8?q?=5Ftest.c=20=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B9=D0=B4=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D1=81=D1=80=D0=B0=D0=B7=D1=83=20=D0=B6=D0=B5!=20=D0=A3=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D1=81=D1=8C!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- c/zalloc_ext/zalloc_ext.geany | 13 +++--- c/zalloc_ext/zalloc_ext_test.c | 72 +++++++++++++++++++++------------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/c/zalloc_ext/zalloc_ext.geany b/c/zalloc_ext/zalloc_ext.geany index 0c563b4..1c486f7 100644 --- a/c/zalloc_ext/zalloc_ext.geany +++ b/c/zalloc_ext/zalloc_ext.geany @@ -16,12 +16,13 @@ long_line_behaviour=1 long_line_column=72 [files] -current_page=1 -FILE_NAME_0=372;C;0;16;1;1;1;/home/kolan/dev/c/zalloc_ext/zalloc_ext_test.c;0 -FILE_NAME_1=6576;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.c;0 -FILE_NAME_2=0;C;0;16;1;1;1;/home/kolan/projects/include/xerror.h;0 -FILE_NAME_3=2311;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.h;0 -FILE_NAME_4=0;C;0;16;1;1;1;/home/kolan/projects/include/zalloc.h;0 +current_page=0 +FILE_NAME_0=262;C;0;16;1;1;1;/home/kolan/dev/c/zalloc_ext/zalloc_ext_test.c;0 +FILE_NAME_1=8384;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.c;0 +FILE_NAME_2=2684;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.h;0 +FILE_NAME_3=0;C;0;16;1;1;1;/home/kolan/projects/include/zalloc.h;0 +FILE_NAME_4=0;C;0;16;1;1;1;/home/kolan/projects/include/xalloc.h;0 +FILE_NAME_5=1193;Make;0;16;1;1;1;/home/kolan/dev/c/zalloc_ext/Makefile;0 [build-menu] NF_00_LB=_Сделать diff --git a/c/zalloc_ext/zalloc_ext_test.c b/c/zalloc_ext/zalloc_ext_test.c index 71a980b..88097d2 100644 --- a/c/zalloc_ext/zalloc_ext_test.c +++ b/c/zalloc_ext/zalloc_ext_test.c @@ -25,33 +25,51 @@ int main() zptr2 = zalloc_append_usual(zptr2, arr, 9832472); zptr4_str = zalloc_append_usual_str(zptr4_str, " - twice :)"); puts(zptr4_str); - //~ zalloc_append8(zdest, elem); - //~ zalloc_append8_str(zdest, elem); - //~ zalloc_append16(zdest, elem); - //~ zalloc_append16_str(zdest, elem); - //~ zalloc_append32(zdest, elem); - //~ zalloc_append32_str(zdest, elem); - //~ zalloc_append64(zdest, elem); - //~ zalloc_append64_str(zdest, elem); -//~ - //~ /* Cut/Copy/Insert functions - //~ */ - //~ zalloc_cut(zptr, off, len); - //~ zalloc_cut_str(zptr, off, len); - //~ zalloc_copy(zptr, off, len); - //~ zalloc_copy_str(zptr, off, len); - //~ zalloc_insert(zdest, off, zsrc); - //~ zalloc_insert_str(zdest, off, zsrc); - //~ zalloc_insert_usual(zdest, off, arr, len); - //~ zalloc_insert_usual_str(zdest, off, str); - //~ zalloc_insert8(zptr, off, elem); - //~ zalloc_insert8_str(zptr, off, elem); - //~ zalloc_insert16(zptr, off, elem); - //~ zalloc_insert16_str(zptr, off, elem); - //~ zalloc_insert32(zptr, off, elem); - //~ zalloc_insert32_str(zptr, off, elem); - //~ zalloc_insert64(zptr, off, elem); - //~ zalloc_insert64_str(zptr, off, elem); + zptr = zalloc_append8(zptr, 'a'); + zptr4_str = zalloc_append8_str(zptr4_str, 'E'); + puts(zptr4_str); + zptr = zalloc_append16(zptr, 12345); + zptr4_str = zalloc_append16_str(zptr4_str, ('H' << 8) + 'H'); + puts(zptr4_str); + zptr = zalloc_append32(zptr, 65489498L); + zptr4_str = zalloc_append32_str(zptr4_str, (((((('4' << 8) + '4') << 8) + '4') << 8) + '4')); + puts(zptr4_str); + zptr3 = zalloc_append64(zptr3, 3232423423423LLU); + int64_t i64 = 1561; + int i; + for (i = 0; i < 8; i++) + i64 = (i64 << 8) + '8'; + printf("%x %x %x %x\n", *((char *)&i64 + 0), *((char *)&i64 + 1), *((char *)&i64 + 2), *((char *)&i64 + 3)); + zptr4_str = zalloc_append64_str(zptr4_str, i64); + puts(zptr4_str); + + /* Cut/Copy/Insert functions + */ + zptr3 = zalloc_cut(zptr3, 6547, 564); + zptr4_str = zalloc_cut_str(zptr4_str, 5, 7); + puts(zptr4_str); + void *zptr5 = zalloc_copy(zptr2, 8424, 345); + void *zptr6_str = zalloc_copy_str(zptr4_str, 6, 13); + puts(zptr6_str); + zptr5 = zalloc_insert(zptr5, 0, zptr); + zptr4_str = zalloc_insert_str(zptr4_str, 31, zptr6_str); + puts(zptr4_str); + void *arr2 = zmalloc(54547); + zptr2 = zalloc_insert_usual(zptr2, zalloc_size(zptr2) - 3, arr2, zalloc_size(arr2)); + zptr4_str = zalloc_insert_usual_str(zptr4_str, 5, ":zalloc_insert_usual_str():"); + puts(zptr4_str); + zptr5 = zalloc_insert8(zptr5, 9874, 'd'); + zptr6_str = zalloc_insert8_str(zptr6_str, 0, '0'); + puts(zptr6_str); + zptr5 = zalloc_insert16(zptr5, 9874, 5478); + zptr6_str = zalloc_insert16_str(zptr6_str, 1, ('1' << 8) + '1'); + puts(zptr6_str); + zptr5 = zalloc_insert32(zptr5, 9874, 5478323); + zptr6_str = zalloc_insert32_str(zptr6_str, 0, (((((('4' << 8) + '4') << 8) + '4') << 8) + '4')); + puts(zptr6_str); + zptr5 = zalloc_insert64(zptr5, 9874, 5478433443LU); + zptr6_str = zalloc_insert64_str(zptr6_str, zalloc_size(zptr6_str) - 1, i64); + puts(zptr6_str); return EXIT_SUCCESS; }