Changeset 552da22


Ignore:
Timestamp:
2023-04-01T20:29:42Z (21 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
10425b2
Parents:
a4ac9c4
git-author:
David Cantrell <dcantrell@…> (01-04-23 20:29:42)
git-committer:
GitHub <noreply@…> (01-04-23 20:29:42)
Message:

Use g_memdup2() with glib versions >= 2.68.0 (#168)

  • Use g_memdup2() with glib versions >= 2.68.0

g_memdup() was deprecated in glib 2.68.0. The new function is
g_memdup2(). Still support building with older versions of glib via
macros.

Signed-off-by: David Cantrell <dcantrell@…>

  • Fall back to g_memdup when g_memdup2 is not available, rather than defining custom macro

Signed-off-by: David Cantrell <dcantrell@…>
Co-authored-by: Jelmer Vernooij <jelmer@…>

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.h

    ra4ac9c4 r552da22  
    104104#define g_strncasecmp g_ascii_strncasecmp
    105105
     106/* g_memdup() deprecated as of glib 2.68.0 */
     107#ifndef GLIB_VERSION_2_68
     108#define g_memdup2 g_memdup
     109#endif
     110
    106111#ifndef G_GNUC_MALLOC
    107112/* Doesn't exist in GLib <=2.4 while everything else in BitlBee should
  • lib/http_client.c

    ra4ac9c4 r552da22  
    372372        if (chunk != req->cbuf) {
    373373                req->cblen = eos - chunk;
    374                 s = g_memdup(chunk, req->cblen + 1);
     374                s = g_memdup2(chunk, req->cblen + 1);
    375375                g_free(req->cbuf);
    376376                req->cbuf = s;
     
    462462        /* Separately allocated space for headers and body. */
    463463        req->sblen = req->body_size = req->reply_headers + req->bytes_read - req->reply_body;
    464         req->sbuf = req->reply_body = g_memdup(req->reply_body, req->body_size + 1);
     464        req->sbuf = req->reply_body = g_memdup2(req->reply_body, req->body_size + 1);
    465465        req->reply_headers = g_realloc(req->reply_headers, end1 - req->reply_headers + 1);
    466466
     
    680680
    681681        if (req->reply_body - req->sbuf >= 512) {
    682                 char *new = g_memdup(req->reply_body, req->body_size + 1);
     682                char *new = g_memdup2(req->reply_body, req->body_size + 1);
    683683                g_free(req->sbuf);
    684684                req->reply_body = req->sbuf = new;
  • lib/json_util.c

    ra4ac9c4 r552da22  
    2727
    2828#include "json_util.h"
     29
     30/* g_memdup() deprecated as of glib 2.68.0 */
     31#ifdef GLIB_VERSION_2_68
     32#define g_memdup2 g_memdup2
     33#else
     34#define g_memdup2 g_memdup
     35#endif
    2936
    3037json_value *json_o_get(const json_value *obj, const json_char *name)
     
    6168
    6269        if (ret && ret->type == json_string && ret->u.string.ptr) {
    63                 return g_memdup(ret->u.string.ptr, ret->u.string.length + 1);
     70                return g_memdup2(ret->u.string.ptr, ret->u.string.length + 1);
    6471        } else {
    6572                return NULL;
  • lib/xmltree.c

    ra4ac9c4 r552da22  
    3333#define g_strncasecmp g_ascii_strncasecmp
    3434
     35/* g_memdup() deprecated as of glib 2.68.0 */
     36#ifdef GLIB_VERSION_2_68
     37#define g_memdup2 g_memdup2
     38#else
     39#define g_memdup2 g_memdup
     40#endif
     41
    3542static void xt_start_element(GMarkupParseContext *ctx, const gchar *element_name, const gchar **attr_names,
    3643                             const gchar **attr_values, gpointer data, GError **error)
     
    364371        dup->flags = node->flags;
    365372        if (node->text) {
    366                 dup->text = g_memdup(node->text, node->text_len + 1);
     373                dup->text = g_memdup2(node->text, node->text_len + 1);
    367374                dup->text_len = node->text_len;
    368375        }
  • protocols/bee_user.c

    ra4ac9c4 r552da22  
    201201
    202202        /* May be nice to give the UI something to compare against. */
    203         old = g_memdup(bu, sizeof(bee_user_t));
     203        old = g_memdup2(bu, sizeof(bee_user_t));
    204204
    205205        /* TODO(wilmer): OPT_AWAY, or just state == NULL ? */
     
    239239        }
    240240
    241         old = g_memdup(bu, sizeof(bee_user_t));
     241        old = g_memdup2(bu, sizeof(bee_user_t));
    242242
    243243        bu->status_msg = message && *message ? g_strdup(message) : NULL;
  • protocols/jabber/io.c

    ra4ac9c4 r552da22  
    6363                /* If the queue is empty, allocate a new buffer. */
    6464                jd->tx_len = len;
    65                 jd->txq = g_memdup(buf, len);
     65                jd->txq = g_memdup2(buf, len);
    6666
    6767                /* Try if we can write it immediately so we don't have to do
     
    134134                char *s;
    135135
    136                 s = g_memdup(jd->txq + st, jd->tx_len - st);
     136                s = g_memdup2(jd->txq + st, jd->tx_len - st);
    137137                jd->tx_len -= st;
    138138                g_free(jd->txq);
  • protocols/jabber/jabber.c

    ra4ac9c4 r552da22  
    803803
    804804        /* Another one for hipchat, which has completely different logins */
    805         hipchat = g_memdup(ret, sizeof(struct prpl));
     805        hipchat = g_memdup2(ret, sizeof(struct prpl));
    806806        hipchat->name = "hipchat";
    807807        register_protocol(hipchat);
  • protocols/purple/ft-direct.c

    ra4ac9c4 r552da22  
    7171        struct prpl_xfer_data *px = ft->data;
    7272
    73         px->buf = g_memdup(buffer, len);
     73        px->buf = g_memdup2(buffer, len);
    7474        px->buf_len = len;
    7575
  • protocols/purple/purple.c

    ra4ac9c4 r552da22  
    19371937                }
    19381938
    1939                 ret = g_memdup(&funcs, sizeof(funcs));
     1939                ret = g_memdup2(&funcs, sizeof(funcs));
    19401940                ret->name = ret->data = prot->info->id;
    19411941                if (strncmp(ret->name, "prpl-", 5) == 0) {
  • protocols/twitter/twitter.c

    ra4ac9c4 r552da22  
    11171117
    11181118        /* And an identi.ca variant: */
    1119         ret = g_memdup(ret, sizeof(struct prpl));
     1119        ret = g_memdup2(ret, sizeof(struct prpl));
    11201120        ret->name = "identica";
    11211121        ret->options =  PRPL_OPT_NOOTR;
  • protocols/twitter/twitter_lib.c

    ra4ac9c4 r552da22  
    647647                }
    648648        } else if (text_value && text_value->type == json_string) {
    649                 txs->text = g_memdup(text_value->u.string.ptr, text_value->u.string.length + 1);
     649                txs->text = g_memdup2(text_value->u.string.ptr, text_value->u.string.length + 1);
    650650                strip_html(txs->text);
    651651                expand_entities(&txs->text, node, extended_node);
     
    674674        JSON_O_FOREACH(node, k, v) {
    675675                if (strcmp("text", k) == 0 && v->type == json_string) {
    676                         txs->text = g_memdup(v->u.string.ptr, v->u.string.length + 1);
     676                        txs->text = g_memdup2(v->u.string.ptr, v->u.string.length + 1);
    677677                        strip_html(txs->text);
    678678                } else if (strcmp("created_at", k) == 0 && v->type == json_string) {
Note: See TracChangeset for help on using the changeset viewer.