Snort mailing list archives
Improved strncpy for Snort...
From: Bill Parker <wp02855 () gmail com>
Date: Fri, 22 May 2015 10:27:15 -0700
Hello All, I was wondering if improvements to strncpy() would have any impact on snort performance, and here is a function (also implemented as a macro) which can cut down on use of strncpy: int Snort_Strrncmp(char *, char *, int); /* function prototype */ /* This function implements a faster version of the C library */ /* function 'strncmp', by comparing the first character of */ /* each string, and if a MATCH is found, then call 'strncmp' */ /* to make a more exact comparison. The expected speed up by */ /* using this routine is approximately 15 to 1 (given the */ /* distribution of letters in the alphabet */ int Snort_Strncmp(const char *str1, const char *str2, int n) { if (*str1 != *str2) return (int) ((unsigned char) *(str1) -(unsigned char) *(str2)); else return strncmp(str1, str2, n); } Here is the above function as a #define macro: #define Snort_Strncmp(a,b,c) (*(a) != *(b) ? \ (int) ((unsigned char) *(a) - \ (unsigned char) *(b)) : \ strncmp((a), (b), (c))) Comments anyone? Bill
------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________ Snort-devel mailing list Snort-devel () lists sourceforge net https://lists.sourceforge.net/lists/listinfo/snort-devel Archive: http://sourceforge.net/mailarchive/forum.php?forum_name=snort-devel Please visit http://blog.snort.org for the latest news about Snort!
Current thread:
- Improved strncpy for Snort... Bill Parker (May 22)