2 Star 1 Fork 0

TappaT/clixon-libevhtp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
numtoa.c 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* DERIVED FROM the stringencoders library's modp_numtoa
*
* Copyright ; 2007, Nick Galbreath -- nickg [at] client9 [dot] com
* All rights reserved.
* http://code.google.com/p/stringencoders/
* Released under the MIT license.
*
*/
#ifdef HAVE_CONFIG_H
#include "libevhtp-config.h" /* generated by config & autoconf */
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "internal.h"
#include "numtoa.h"
static inline void
strreverse(char * begin, char * end) {
char aux;
while (end > begin) {
aux = *end, *end-- = *begin, *begin++ = aux;
}
}
size_t
evhtp_modp_u64toa(uint64_t value, char * str) {
char * wstr = str;
/* Conversion. Number is reversed. */
do {
*wstr++ = (char)(48 + (value % 10));
} while (value /= 10);
*wstr = '\0';
/* Reverse string */
strreverse(str, wstr - 1);
return (size_t)(wstr - str);
}
size_t
evhtp_modp_u32toa(uint32_t value, char * str) {
char * wstr = str;
/* Conversion. Number is reversed. */
do {
*wstr++ = (char)(48 + (value % 10));
} while (value /= 10);
*wstr = '\0';
/* Reverse string */
strreverse(str, wstr - 1);
return (size_t)(wstr - str);
}
inline size_t
evhtp_modp_sizetoa(size_t value, char * str) {
#if TARGET_CPU == x86_64
return evhtp_modp_u64toa(value, str);
#elif TARGET_CPU == i686
return evhtp_modp_u32toa(value, str);
#elif TARGET_CPU == armv71
return evhtp_modp_u32toa(value, str);
#else
#warning "UNKNOWN ARCH"
#endif
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/TappaT/clixon-libevhtp.git
git@gitee.com:TappaT/clixon-libevhtp.git
TappaT
clixon-libevhtp
clixon-libevhtp
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385