-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: memrchr() is non-POSIX, check for it on configure
- Loading branch information
Showing
4 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "memrchr.h" | ||
void *memrchr(const void *s, int c, size_t n) { | ||
const char *start = s; | ||
const char *end = &start[n]; //one too much on purpose | ||
while(--end >= start) { //and this is why | ||
if(c == *end) { | ||
return (void *)end; | ||
} | ||
} | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef NCHAN_MEMRCHR_H | ||
#define NCHAN_MEMRCHR_H | ||
#include <string.h> | ||
#include <stddef.h> | ||
|
||
void *memrchr(const void *s, int c, size_t n); | ||
|
||
#endif /*NCHAN_MEMRCHR_H*/ |