摘要: #ifndef STRING_H#define STRING_H#define STRING_DEFAULT_CHUNK_SIZE 256typedef struct { char *value; int length; int capacity; int chunk_size;} String;String *string_construct(const char *value);String *string_construct_from_int(int value);void string_destroy(String *string);void string_se... 阅读全文
posted @ 2011-09-27 12:52 火腿骑士 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 栈实际应用现场:先入后出(顺序栈)#include "linkedlist.h"#include <stdlib.h>#include <stdio.h>#ifdef DMALLOC#include "dmalloc.h"#endiftypedef struct { LinkedList *list;} StackStack *stack_construct() { Stack *stack = NULL; stack = calloc(1, sizeof(Stack));if (stack == NULL) { return N 阅读全文
posted @ 2011-09-27 12:50 火腿骑士 阅读(198) 评论(0) 推荐(0) 编辑
摘要: #include "logger.h"#include <stdio.h>#include <sys/types.h>#include <time.h>#include <ctype.h>#include <sys/time.h>#include <time.h>#include <stdlib.h>#include <string.h>#define tAGO 257#define tDAY 258#define tDAY_UNIT 259#define tDAYZONE 26 阅读全文
posted @ 2011-09-27 12:47 火腿骑士 阅读(450) 评论(0) 推荐(0) 编辑
摘要: #include <time.h>#include "date.h"#include "gettimestamp.h"#include "logger.h"#include <time.h>#include <locale.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#ifdef DMALLOC#include "dmalloc.h"#endiftypedef struct 阅读全文
posted @ 2011-09-27 12:42 火腿骑士 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 队列实际应用现场:先入先出#include "queue.h"#include "linkedlist.h"#include <stdlib.h>#include <stdio.h>#ifdef DMALLOC#include "dmalloc.h"#endiftypedef struct { LinkedList *list;} Queue;Queue *queue_construct() { Queue *queue = NULL; /* * Allocate space for the object an 阅读全文
posted @ 2011-09-27 12:39 火腿骑士 阅读(364) 评论(2) 推荐(0) 编辑
摘要: #ifndef FILE_H#define FILE_H#include "descriptor.h"#include "date.h"#include "dictionary.h"#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/time.h>#include <sys/types.h>#include <time.h>#include <unistd.h& 阅读全文
posted @ 2011-09-27 11:56 火腿骑士 阅读(213) 评论(0) 推荐(0) 编辑
摘要: #ifndef LINKED_LIST_H#define LINKED_LIST_Htypedef struct LinkedListNode { const void *data; struct LinkedListNode *prev; struct LinkedListNode *next;} LinkedListNode; typedef struct { LinkedListNode *head; LinkedListNode *current; LinkedListNode *tail; int size;} LinkedList;#define... 阅读全文
posted @ 2011-09-27 11:54 火腿骑士 阅读(229) 评论(0) 推荐(0) 编辑
摘要: #include <string.h>#include <stdlib.h>typedef struct LinkedList { char *s; struct LinkedList *next;} LinkedList;void freell(LinkedList *list){ LinkedList *cur = list; if(list == NULL) return; freell(list->next); free(list->s); free(list);}LinkedList *createll(char *s){ LinkedList * 阅读全文
posted @ 2011-09-27 11:45 火腿骑士 阅读(220) 评论(0) 推荐(0) 编辑
摘要: typedef struct _list { struct _list* plPrev; struct _list* plNext; void* p;} list;int ListCreate( list *pl ) { pl->plPrev = pl->plNext = pl; pl->p = NULL; return 0;}list *ListInsert( list *pl, void *p ) { list *plNew; if ( (plNew = (list*)malloc( sizeof( *plNew ))) == NULL )return NULL; plN 阅读全文
posted @ 2011-09-27 10:22 火腿骑士 阅读(248) 评论(0) 推荐(0) 编辑
摘要: #ifdef HAVE_CONFIG_H# include <config.h>#endif#include <errno.h>#include <stdlib.h>#include <string.h>#include <list0.h>#include <iterator0.h>#include <mailutils/errno.h>intmu_list_create (mu_list_t *plist){ mu_list_t list; int status; if (plist == NULL) ret 阅读全文
posted @ 2011-09-27 10:15 火腿骑士 阅读(271) 评论(0) 推荐(0) 编辑