jolly has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/34475?usp=email )


Change subject: HACK, DON'T MERGE!: remove calloc from libosmocore
......................................................................

HACK, DON'T MERGE!: remove calloc from libosmocore

Change-Id: Ifd0560df0b8a9765c0a0b8939bec917b323382d7
---
M src/shared/libosmocore/src/gsm/gsm_utils.c
1 file changed, 11 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/75/34475/1

diff --git a/src/shared/libosmocore/src/gsm/gsm_utils.c 
b/src/shared/libosmocore/src/gsm/gsm_utils.c
index 4b170df..9446ff4 100644
--- a/src/shared/libosmocore/src/gsm/gsm_utils.c
+++ b/src/shared/libosmocore/src/gsm/gsm_utils.c
@@ -202,7 +202,7 @@
        int i = 0, z = 0;
        uint8_t cb, nb;
        int shift = 0;
-       uint8_t *data = calloc(septet_len + 1, sizeof(uint8_t));
+       uint8_t data[septet_len + 1];

        if (padding) {
                shift = 7 - padding;
@@ -237,8 +237,6 @@
                shift++;
        }

-       free(data);
-
        return z;
 }

@@ -248,12 +246,10 @@
        int y = 0;

        /* prepare for the worst case, every character expanding to two bytes */
-       uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t));
+       uint8_t rdata[strlen(data) * 2];
        y = gsm_septet_encode(rdata, data);
        gsm_septets2octets(result, rdata, y, 0);

-       free(rdata);
-
        /*
         * We don't care about the number of octets, because they are not
         * unique. E.g.:

--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/34475?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ifd0560df0b8a9765c0a0b8939bec917b323382d7
Gerrit-Change-Number: 34475
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <[email protected]>
Gerrit-MessageType: newchange

Reply via email to