-
memstr
/*********************** internal functions *********************/ /* search for a string in a fixed-length byte string. if partial is true, partial matches are allowed at the end of the buffer. returns NULL if not found, or a pointer to the start of the first match. */ void* my_memstr(char* haystack, int haystacklen, const char* needle, int partial) { int needlen = strlen(needle); int len = haystacklen; char *ptr = haystack; /* iterate through first character matches */ while( (ptr = memchr(ptr, needle[0], len)) ) { /* calculate length after match */ len = haystacklen - (ptr - (char *)haystack); /* done if matches up to capacity of buffer */ if(memcmp(needle, ptr, needlen < len ? needlen : len) == 0 && (partial || len >= needlen)) break; /* next character */ ptr++; len--; } return ptr; }
-
相关阅读:
Unity3D Editor模式下批量修改prefab
3D touch在Unity3D中的使用
Unity中的协程是什么?
Unity3D脚本调用Objective C代码实现游戏内购买
WindowsPhone8拍照功能实现简介
WindowsPhone App如何扩展能够使用的内存
SVN 提交代码时提示文件已经存在解决办法
iOS检查App新版本并更新新版本
iOS存储数据字典到沙盒
统计整个Xcode工程代码行数
-
原文地址:https://www.cnblogs.com/lexus/p/3001106.html
Copyright © 2020-2023
润新知