Files
org-hyperion-cules/memrchr.c
Jan Jaeger 439bdbca92 Remove subversion $Id$ tag
Update copyright statement to 2012
2012-03-24 18:41:51 +11:00

38 lines
976 B
C

/* MEMRCHR.C (c) Copyright Roger Bowler, 2006-2012 */
/* Hercules Right to Left memory scan */
/* */
/* Released under "The Q Public License Version 1" */
/* (http://www.hercules-390.org/herclic.html) as modifications to */
/* Hercules. */
#include "hstdinc.h"
#define _MEMRCHR_C_
#define _HUTIL_DLL_
#include "hercules.h"
#if !defined( HAVE_MEMRCHR )
#include "memrchr.h"
DLL_EXPORT void *memrchr(const void *buf, int c, size_t num)
{
unsigned char *pMem;
if (num == 0)
{
return NULL;
}
for (pMem = (unsigned char *) buf + num - 1; pMem >= (unsigned char *) buf; pMem--)
{
if (*pMem == (unsigned char) c) break;
}
if (pMem >= (unsigned char *) buf)
{
return ((void *) pMem);
}
return NULL;
}
#endif // !defined(HAVE_MEMRCHR)