abc_begin

导航

09 2017 档案

nginx源码学习_源码结构
摘要:nginx的优秀除了体现在程序结构以及代码风格上,nginx的源码组织也同样简洁明了,目录结构层次结构清晰,值得我们去学习。nginx的源码目录与nginx的模块化以及功能的划分是紧密结合,这也使得我们可以很方便地找到相关功能的代码。 下面是nginx源码的目录结构: 对于上面src文件夹,输出结果 阅读全文

posted @ 2017-09-30 14:16 LastBattle 阅读(1174) 评论(0) 推荐(0)

nginx 模块简介
摘要:nginx模块一般分为5类:核心模块、标准http模块、可选http模块、邮件服务模块、第三方模块。 其中核心模块和标准http模块在快速编译之后就包含在了nginx中。 主要看一下核心模块、标准http模块和可选http模块,这些模块都可以在ngx_modules.c中找到: 1、核心模块 上面的 阅读全文

posted @ 2017-09-30 11:26 LastBattle 阅读(477) 评论(0) 推荐(0)

nginx configure参数
摘要:下面是nginx源码程序的configure参数: --prefix= 指向安装目录。默认为:/usr/local/nginx --sbin-path= 指定执行程序文件存放位置。默认为:prefix/sbin/nginx --modules-path= 指定第三方模块的存放路径。 --conf-p 阅读全文

posted @ 2017-09-29 16:39 LastBattle 阅读(356) 评论(0) 推荐(0)

libevent源码学习_event_test
摘要:对应的sample文件中提供了event_test.c,里面就是关于事件的简单示例,具体如下: 从这个例子中,我们可以看到使用libevent的基本步骤: event_init --> event_set --> event_add --> event_dispatch 下面分步来解析这些函数。 1 阅读全文

posted @ 2017-09-27 17:57 LastBattle 阅读(514) 评论(0) 推荐(0)

libevent源码学习_event结构体
摘要:在libevent中最重要的结构体莫过于event和event_base了,下面对于这2个结构体进行分析。 1、结构体event,位于:event.h 2、结构体event_base,位于:event_internal.h 3、结构体eventop,位于:event_internal.h 实际真正使 阅读全文

posted @ 2017-09-27 16:24 LastBattle 阅读(695) 评论(0) 推荐(0)

do{...}while(0)的意义和用法
摘要:linux内核和其他一些开源的代码中,经常会遇到这样的代码: 这样的代码一看就不是一个循环,do..while表面上在这里一点意义都没有,那么为什么要这么用呢? 实际上,do{...}while(0)的作用远大于美化你的代码。查了些资料,总结起来这样写主要有以下几点好处: 1、辅助定义复杂的宏,避免 阅读全文

posted @ 2017-09-27 11:30 LastBattle 阅读(300) 评论(0) 推荐(0)

345. Reverse Vowels of a String【easy】
摘要:345. Reverse Vowels of a String【easy】 Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hell 阅读全文

posted @ 2017-09-23 23:29 LastBattle 阅读(168) 评论(0) 推荐(0)

551. Student Attendance Record I【easy】
摘要:551. Student Attendance Record I【easy】 You are given a string representing an attendance record for a student. The record only contains the following 阅读全文

posted @ 2017-09-23 22:59 LastBattle 阅读(173) 评论(0) 推荐(0)

383. Ransom Note【easy】
摘要:383. Ransom Note【easy】 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will 阅读全文

posted @ 2017-09-23 19:08 LastBattle 阅读(190) 评论(0) 推荐(0)

657. Judge Route Circle【easy】
摘要:657. Judge Route Circle【easy】 Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which 阅读全文

posted @ 2017-09-23 18:51 LastBattle 阅读(190) 评论(0) 推荐(0)

606. Construct String from Binary Tree 【easy】
摘要:606. Construct String from Binary Tree 【easy】 You need to construct a string consists of parenthesis and integers from a binary tree with the preorder 阅读全文

posted @ 2017-09-23 18:44 LastBattle 阅读(193) 评论(0) 推荐(0)

520. Detect Capital【easy】
摘要:520. Detect Capital【easy】 Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a wo 阅读全文

posted @ 2017-09-23 18:23 LastBattle 阅读(308) 评论(0) 推荐(0)

28. Implement strStr()【easy】
摘要:28. Implement strStr()【easy】 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of hayst 阅读全文

posted @ 2017-09-23 17:43 LastBattle 阅读(154) 评论(0) 推荐(0)

521. Longest Uncommon Subsequence I【easy】
摘要:521. Longest Uncommon Subsequence I【easy】 Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings 阅读全文

posted @ 2017-09-23 17:36 LastBattle 阅读(121) 评论(0) 推荐(0)

344. Reverse String【easy】
摘要:344. Reverse String【easy】 Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". 解法 阅读全文

posted @ 2017-09-23 17:21 LastBattle 阅读(224) 评论(0) 推荐(0)

557. Reverse Words in a String III【easy】
摘要:557. Reverse Words in a String III【easy】 Given a string, you need to reverse the order of characters in each word within a sentence while still preser 阅读全文

posted @ 2017-09-23 17:10 LastBattle 阅读(229) 评论(0) 推荐(0)

680. Valid Palindrome II【easy】
摘要:680. Valid Palindrome II【easy】 Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1 阅读全文

posted @ 2017-09-23 16:56 LastBattle 阅读(679) 评论(0) 推荐(0)

125. Valid Palindrome【easy】
摘要:125. Valid Palindrome【easy】 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, 阅读全文

posted @ 2017-09-23 15:38 LastBattle 阅读(141) 评论(0) 推荐(0)

459. Repeated Substring Pattern【easy】
摘要:459. Repeated Substring Pattern【easy】 Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copie 阅读全文

posted @ 2017-09-23 12:58 LastBattle 阅读(166) 评论(0) 推荐(0)

nginx源码学习_数据结构(ngx_pool_t)
该文被密码保护。

posted @ 2017-09-20 17:17 LastBattle 阅读(139) 评论(0) 推荐(0)

2. Trailing Zeros【easy】
摘要:2. Trailing Zeros【easy】 Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this question in a real interview? 阅读全文

posted @ 2017-09-20 16:34 LastBattle 阅读(211) 评论(0) 推荐(0)

142. O(1) Check Power of 2【easy】
摘要:142. O(1) Check Power of 2【easy】 Using O(1) time to check whether an integer n is a power of 2. Have you met this question in a real interview? Yes Ex 阅读全文

posted @ 2017-09-20 15:59 LastBattle 阅读(115) 评论(0) 推荐(0)

181. Flip Bits【easy】
摘要:181. Flip Bits【easy】 Determine the number of bits required to flip if you want to convert integer n to integer m. Notice Both n and m are 32-bit integ 阅读全文

posted @ 2017-09-20 15:52 LastBattle 阅读(193) 评论(0) 推荐(0)

183.Wood Cut【hard】
摘要:183.Wood Cut【hard】 Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than 阅读全文

posted @ 2017-09-19 17:20 LastBattle 阅读(384) 评论(0) 推荐(0)

61. Search for a Range【medium】
摘要:61. Search for a Range【medium】 Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not 阅读全文

posted @ 2017-09-19 16:36 LastBattle 阅读(160) 评论(0) 推荐(0)

62. Search in Rotated Sorted Array【medium】
摘要:62. Search in Rotated Sorted Array【medium】 Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might becom 阅读全文

posted @ 2017-09-19 15:53 LastBattle 阅读(151) 评论(0) 推荐(0)

74. First Bad Version 【medium】
摘要:74. First Bad Version 【medium】 The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it 阅读全文

posted @ 2017-09-19 14:24 LastBattle 阅读(139) 评论(0) 推荐(0)

75. Find Peak Element 【medium】
摘要:75. Find Peak Element 【medium】 There is an integer array which has the following features: The numbers in adjacent positions are different. A[0] < A[1 阅读全文

posted @ 2017-09-19 14:13 LastBattle 阅读(130) 评论(0) 推荐(0)

159. Find Minimum in Rotated Sorted Array 【medium】
摘要:159. Find Minimum in Rotated Sorted Array 【medium】 Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 mig 阅读全文

posted @ 2017-09-18 17:05 LastBattle 阅读(107) 评论(0) 推荐(0)

14. First Position of Target 【easy】
摘要:14. First Position of Target 【easy】 For a given sorted array (ascending order) and a targetnumber, find the first index of this number in O(log n) tim 阅读全文

posted @ 2017-09-18 16:45 LastBattle 阅读(264) 评论(0) 推荐(0)

28. Search a 2D Matrix 【easy】
摘要:28. Search a 2D Matrix 【easy】 Write an efficient algorithm that searches for a value in an mx n matrix. This matrix has the following properties: Inte 阅读全文

posted @ 2017-09-18 16:20 LastBattle 阅读(266) 评论(0) 推荐(0)

60. Search Insert Position 【easy】
摘要:60. Search Insert Position 【easy】 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it 阅读全文

posted @ 2017-09-18 15:57 LastBattle 阅读(178) 评论(0) 推荐(0)

141. Sqrt(x) 【easy】
摘要:141. Sqrt(x) 【easy】 Implement int sqrt(int x). Compute and return the square root of x. Example sqrt(3) = 1 sqrt(4) = 2 sqrt(5) = 2 sqrt(10) = 3 Chall 阅读全文

posted @ 2017-09-18 15:37 LastBattle 阅读(167) 评论(0) 推荐(0)

nginx源码学习_数据结构(ngx_str_t)
摘要:nginx中关于字符串的数据结构位于src/core/ngx_string.c和src/core/ngx_string.h中 先来看一下数据结构: data指针指向字符串起始地址,len表示字符串的有效长度。这里面的data并不保证以'\0'结尾,所以必须配合len去使用,否则极其容易造成缓冲区溢出 阅读全文

posted @ 2017-09-18 15:13 LastBattle 阅读(1254) 评论(0) 推荐(0)

nginx源码学习_数据结构(ngx_int_t)
摘要:nginx中关于整型的数据结构位于src/core/ngx_config.h中 结构比较简单,就是一个typedef的操作,具体如下: 里面的intptr_t和uintptr_t的定义位于/usr/include/stdint.h中 另外,C99 标准定义了 intptr_t 和 uintptr_t 阅读全文

posted @ 2017-09-18 11:45 LastBattle 阅读(832) 评论(0) 推荐(0)

661. Image Smoother【easy】
摘要:661. Image Smoother【easy】 Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of 阅读全文

posted @ 2017-09-17 23:31 LastBattle 阅读(303) 评论(0) 推荐(0)

27. Remove Element【easy】
摘要:27. Remove Element【easy】 Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra spac 阅读全文

posted @ 2017-09-17 22:47 LastBattle 阅读(267) 评论(0) 推荐(0)

26. Remove Duplicates from Sorted Array【easy】
摘要:26. Remove Duplicates from Sorted Array【easy】 Given a sorted array, remove the duplicates in place such that each element appear only once and return 阅读全文

posted @ 2017-09-17 22:31 LastBattle 阅读(160) 评论(0) 推荐(0)

88. Merge Sorted Array【easy】
摘要:88. Merge Sorted Array【easy】 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that num 阅读全文

posted @ 2017-09-17 22:12 LastBattle 阅读(185) 评论(0) 推荐(0)

605. Can Place Flowers【easy】
摘要:605. Can Place Flowers【easy】 Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be pla 阅读全文

posted @ 2017-09-17 19:35 LastBattle 阅读(203) 评论(0) 推荐(0)

485. Max Consecutive Ones【easy】
摘要:485. Max Consecutive Ones【easy】 Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 阅读全文

posted @ 2017-09-17 18:49 LastBattle 阅读(127) 评论(0) 推荐(0)

448. Find All Numbers Disappeared in an Array【easy】
摘要:448. Find All Numbers Disappeared in an Array【easy】 Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and 阅读全文

posted @ 2017-09-17 18:30 LastBattle 阅读(192) 评论(0) 推荐(0)

1. Two Sum【easy】
摘要:1. Two Sum【easy】 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each in 阅读全文

posted @ 2017-09-17 16:36 LastBattle 阅读(153) 评论(0) 推荐(0)

189. Rotate Array【easy】
摘要:189. Rotate Array【easy】 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated 阅读全文

posted @ 2017-09-17 16:21 LastBattle 阅读(185) 评论(0) 推荐(0)

redis源码学习_字典
摘要:redis中字典有以下要点: (1)它就是一个键值对,对于hash冲突的处理采用了头插法的链式存储来解决。 (2)对rehash,扩展就是取第一个大于等于used * 2的2 ^ n的数作为新的hash表大小;缩紧就是取第一个大于等于used的2 ^ n的数作为新的hash表大小。后面会介绍到dic 阅读全文

posted @ 2017-09-17 13:50 LastBattle 阅读(502) 评论(0) 推荐(0)

redis源码学习_整数集合
摘要:redis里面的整数集合保存的都是整数,有int_16、int_32和int_64这3种类型,和C++中的set容器差不多。 同时具备如下特点: 1、set里面的数不重复,均为唯一。 2、set里面的数是从小到大有序的,这在后面的intsetAdd函数中可以看到。 然后由于我们可以同时存储int_1 阅读全文

posted @ 2017-09-16 22:57 LastBattle 阅读(844) 评论(1) 推荐(0)

redis源码学习_链表
摘要:redis的链表是双向链表,该链表不带头结点,具体如下: 主要总结一下adlist.c和adlist.h里面的关键结构体和函数。 链表节点结构如下: 链表结构如下: 链表迭代器的结构如下: 里面涉及的函数中,增、删的比较简单,就是结构里面没有带头结点,所以需要单独判断一下头结点的特殊情况。另外对于尾 阅读全文

posted @ 2017-09-16 21:29 LastBattle 阅读(232) 评论(0) 推荐(0)

redis源码学习_简单动态字符串
摘要:SDS相比传统C语言的字符串有以下好处: (1)空间预分配和惰性释放,这就可以减少内存重新分配的次数 (2)O(1)的时间复杂度获取字符串的长度 (3)二进制安全 主要总结一下sds.c和sds.h中的关键函数 1、sdsmapchars 2、sdstrim 3、sdsll2str 4、sdsspl 阅读全文

posted @ 2017-09-16 12:32 LastBattle 阅读(653) 评论(1) 推荐(0)