Implementing sbrk for a custom allocator in C
Interface: consider accepting larger types than int.  The Linux man page says:

Various systems use various types for the argument of sbrk().  Common are int, ssize_t, ptrdiff_t, intptr_t.

ptrdiff_t seems like the most appropriate choice.  Of course, it doesn't really matter with this implementation, as the capacity is less than 32768, and so even a minimal INT_MAX allocation will fail.


if(((char*)p_break + increment) &lt; (char*)global_mem)


Since we have no guarantee that p_break + increment won't overflow, we should re-write that as:
if (increment &lt; global_mem - (char*)p_break)

We know that global_mem - p_break can't overflow, as they are pointers into the same object.
Similarly,

if(((char*)p_break + increment) &gt; (char*)final_address)


should be rewritten as
if (increment &gt; (char*)final_address - (char*)p_break)


We can avoid all the casts here by using char* pointers rather than void* - only the public interface needs the void*.

I hope the ERR macro is compiled out in non-debug builds - users certainly won't want or expect output from sbrk.
The error paths should set errno to ENOMEM.

Modified code
#include &lt;errno.h&gt;

#define MEMORY_CAPACITY 20000

void *mov_sbrk(int increment)
{
    static char global_mem[MEMORY_CAPACITY] = {0};
    static char *p_break = global_mem;

    char *const limit = global_mem + MEMORY_CAPACITY;
    char *const original = p_break;

    if (increment &lt; global_mem - p_break  ||  increment &gt;= limit - p_break)
    {
        errno = ENOMEM;
        return (void*)-1;
    }
    p_break += increment;

    return original;
}

(I moved the global variables into the function to reduce their scope; that might not be appropriate if you also want to implement brk(), but I'm only reviewing the code I see!)