Use consistent naming for OOM
All checks were successful
CI / build-and-analyze (push) Successful in 1m12s
All checks were successful
CI / build-and-analyze (push) Successful in 1m12s
This commit is contained in:
2
CgeNet.h
2
CgeNet.h
@@ -8,7 +8,7 @@ enum CgeNetCode {
|
|||||||
CGE_NET_EOK,
|
CGE_NET_EOK,
|
||||||
CGE_NET_EUNKNOWN,
|
CGE_NET_EUNKNOWN,
|
||||||
CGE_NET_EINVAL,
|
CGE_NET_EINVAL,
|
||||||
CGE_NET_ENOMEM,
|
CGE_NET_EOOM,
|
||||||
CGE_NET_EADDRINUSE,
|
CGE_NET_EADDRINUSE,
|
||||||
CGE_NET_EADDRNOTAVAIL,
|
CGE_NET_EADDRNOTAVAIL,
|
||||||
CGE_NET_ECONNREFUSED,
|
CGE_NET_ECONNREFUSED,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ static int errnoToErrorCode(int value) {
|
|||||||
return CGE_NET_EINVAL;
|
return CGE_NET_EINVAL;
|
||||||
|
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
return CGE_NET_ENOMEM;
|
return CGE_NET_EOOM;
|
||||||
|
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
return CGE_NET_EWOULDBLOCK;
|
return CGE_NET_EWOULDBLOCK;
|
||||||
@@ -29,7 +29,7 @@ CgeNetPoll *CgeNetPollCreate(int *result) {
|
|||||||
|
|
||||||
if (!(poll = malloc(sizeof(CgeNetPoll)))) {
|
if (!(poll = malloc(sizeof(CgeNetPoll)))) {
|
||||||
if (result)
|
if (result)
|
||||||
*result = CGE_NET_ENOMEM;
|
*result = CGE_NET_EOOM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ CgeNetPoll *CgeNetPollCreate(int *result) {
|
|||||||
free(poll);
|
free(poll);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
*result = CGE_NET_ENOMEM;
|
*result = CGE_NET_EOOM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ static int ensureCapacity(CgeNetPoll *poll) {
|
|||||||
if (!newData || !newPfd) {
|
if (!newData || !newPfd) {
|
||||||
free(newData);
|
free(newData);
|
||||||
free(newPfd);
|
free(newPfd);
|
||||||
poll->lastError = CGE_NET_ENOMEM;
|
poll->lastError = CGE_NET_EOOM;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
memcpy(newData, poll->data, poll->size * sizeof(struct PollData));
|
memcpy(newData, poll->data, poll->size * sizeof(struct PollData));
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ static int errnoToErrorCode(int value) {
|
|||||||
return CGE_NET_EINVAL;
|
return CGE_NET_EINVAL;
|
||||||
|
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
return CGE_NET_ENOMEM;
|
return CGE_NET_EOOM;
|
||||||
|
|
||||||
case ETIMEDOUT:
|
case ETIMEDOUT:
|
||||||
return CGE_NET_ETIMEDOUT;
|
return CGE_NET_ETIMEDOUT;
|
||||||
@@ -88,7 +88,7 @@ static int socketInit(CgeNetSocket *s, int domain, int type) {
|
|||||||
|
|
||||||
CgeNetSocket *CgeNetOpen(int domain, int type, int *result) {
|
CgeNetSocket *CgeNetOpen(int domain, int type, int *result) {
|
||||||
CgeNetSocket *socket;
|
CgeNetSocket *socket;
|
||||||
int code = CGE_NET_ENOMEM;
|
int code = CGE_NET_EOOM;
|
||||||
|
|
||||||
if ((socket = malloc(sizeof(*socket)))) {
|
if ((socket = malloc(sizeof(*socket)))) {
|
||||||
if ((code = socketInit(socket, domain, type))) {
|
if ((code = socketInit(socket, domain, type))) {
|
||||||
@@ -220,7 +220,7 @@ CgeNetSocket *CgeNetAccept(CgeNetSocket *socket, CgeNetAddr *addr) {
|
|||||||
|
|
||||||
if (!(client = malloc(sizeof(*client)))) {
|
if (!(client = malloc(sizeof(*client)))) {
|
||||||
close(fd);
|
close(fd);
|
||||||
socket->lastError = CGE_NET_ENOMEM;
|
socket->lastError = CGE_NET_EOOM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ static int wsaToErrorCode(int value) {
|
|||||||
|
|
||||||
case WSAENOBUFS:
|
case WSAENOBUFS:
|
||||||
case WSA_NOT_ENOUGH_MEMORY:
|
case WSA_NOT_ENOUGH_MEMORY:
|
||||||
return CGE_NET_ENOMEM;
|
return CGE_NET_EOOM;
|
||||||
|
|
||||||
case WSAEWOULDBLOCK:
|
case WSAEWOULDBLOCK:
|
||||||
return CGE_NET_EWOULDBLOCK;
|
return CGE_NET_EWOULDBLOCK;
|
||||||
@@ -30,7 +30,7 @@ CgeNetPoll *CgeNetPollCreate(int *result) {
|
|||||||
|
|
||||||
if (!(poll = malloc(sizeof(CgeNetPoll)))) {
|
if (!(poll = malloc(sizeof(CgeNetPoll)))) {
|
||||||
if (result)
|
if (result)
|
||||||
*result = CGE_NET_ENOMEM;
|
*result = CGE_NET_EOOM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ CgeNetPoll *CgeNetPollCreate(int *result) {
|
|||||||
free(poll);
|
free(poll);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
*result = CGE_NET_ENOMEM;
|
*result = CGE_NET_EOOM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ static int ensureCapacity(CgeNetPoll *poll) {
|
|||||||
if (!newData || !newPfd) {
|
if (!newData || !newPfd) {
|
||||||
free(newData);
|
free(newData);
|
||||||
free(newPfd);
|
free(newPfd);
|
||||||
poll->lastError = CGE_NET_ENOMEM;
|
poll->lastError = CGE_NET_EOOM;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
memcpy(newData, poll->data, poll->size * sizeof(struct PollData));
|
memcpy(newData, poll->data, poll->size * sizeof(struct PollData));
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ static int wsaToErrorCode(int value) {
|
|||||||
|
|
||||||
case WSAENOBUFS:
|
case WSAENOBUFS:
|
||||||
case WSA_NOT_ENOUGH_MEMORY:
|
case WSA_NOT_ENOUGH_MEMORY:
|
||||||
return CGE_NET_ENOMEM;
|
return CGE_NET_EOOM;
|
||||||
|
|
||||||
case WSAEADDRINUSE:
|
case WSAEADDRINUSE:
|
||||||
return CGE_NET_EADDRINUSE;
|
return CGE_NET_EADDRINUSE;
|
||||||
@@ -87,7 +87,7 @@ static int socketInit(CgeNetSocket *s, int domain, int type) {
|
|||||||
|
|
||||||
CgeNetSocket *CgeNetOpen(int domain, int type, int *result) {
|
CgeNetSocket *CgeNetOpen(int domain, int type, int *result) {
|
||||||
CgeNetSocket *socket = NULL;
|
CgeNetSocket *socket = NULL;
|
||||||
int code = CGE_NET_ENOMEM;
|
int code = CGE_NET_EOOM;
|
||||||
|
|
||||||
if ((socket = malloc(sizeof(*socket)))) {
|
if ((socket = malloc(sizeof(*socket)))) {
|
||||||
if ((code = socketInit(socket, domain, type))) {
|
if ((code = socketInit(socket, domain, type))) {
|
||||||
@@ -213,7 +213,7 @@ CgeNetSocket *CgeNetAccept(CgeNetSocket *socket, CgeNetAddr *addr) {
|
|||||||
|
|
||||||
if (!(client = malloc(sizeof(*client)))) {
|
if (!(client = malloc(sizeof(*client)))) {
|
||||||
closesocket(fd);
|
closesocket(fd);
|
||||||
socket->lastError = CGE_NET_ENOMEM;
|
socket->lastError = CGE_NET_EOOM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user