Changeset 34509d5


Ignore:
Timestamp:
Dec 23, 2007, 7:48:01 PM (16 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
93ee554
Parents:
9a6cc40
Message:
GLib/Unicode branch - adding glib dependency.

Linking BarnOwl to GLib. 

Cleaning up some malloc/realloc/strdup/free code, moving to owl_*
functions for each.

Changing to GLib memory allocation functions.
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    r9854278 r34509d5  
    948948 
    949949  if (modname) {
    950     if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
     950    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
    951951      /* perror("memrequest: malloc"); */
    952952      return -1;
     
    954954    sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname);
    955955  } else {
    956     if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
     956    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
    957957      /* perror("memrequest: malloc"); */
    958958      return -1;
     
    964964    if (!modname) {
    965965      /* perror("memrequest: stat"); */
    966       free(filename);
     966      owl_free(filename);
    967967      return -1;
    968968    }
     
    986986    int i;
    987987   
    988     free(filename); /* not needed */
     988    owl_free(filename); /* not needed */
    989989    owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
    990990    i = 8;
     
    993993    }
    994994   
    995     if (!(buf = malloc(i))) {
     995    if (!(buf = owl_malloc(i))) {
    996996      return -1;
    997997    }
     
    10171017    *buflenret = i;
    10181018  } else {
    1019     if (!(buf = malloc(len))) {
    1020       free(filename);
     1019    if (!(buf = owl_malloc(len))) {
     1020      owl_free(filename);
    10211021      return -1;
    10221022    }
     
    10241024    if (!(f = fopen(filename, "r"))) {
    10251025      /* perror("memrequest: fopen"); */
    1026       free(filename);
    1027       free(buf);
     1026      owl_free(filename);
     1027      owl_free(buf);
    10281028      return -1;
    10291029    }
    10301030   
    1031     free(filename);
     1031    owl_free(filename);
    10321032   
    10331033    if (fseek(f, offset, SEEK_SET) == -1) {
    10341034      /* perror("memrequest: fseek"); */
    10351035      fclose(f);
    1036       free(buf);
     1036      owl_free(buf);
    10371037      return -1;
    10381038    }
     
    10411041      /* perror("memrequest: fread"); */
    10421042      fclose(f);
    1043       free(buf);
     1043      owl_free(buf);
    10441044      return -1;
    10451045    }
     
    10761076  if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) {
    10771077    aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    1078     free(buf);
     1078    owl_free(buf);
    10791079  } else {
    10801080    owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname);
     
    13421342      int z;
    13431343     
    1344       newbuf = malloc(i+1);
     1344      newbuf = owl_malloc(i+1);
    13451345      for (z = 0; z < i; z++)
    13461346        newbuf[z] = (z % 10)+0x30;
    13471347      newbuf[i] = '\0';
    13481348      /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */
    1349       free(newbuf);
     1349      owl_free(newbuf);
    13501350    }
    13511351  } else if (strstr(tmpstr, "seticqstatus")) {
  • cmd.c

    r6922edd r34509d5  
    7474  owl_cmd *cmd;
    7575
    76   tmpbuff=strdup(cmdbuff);
     76  tmpbuff=owl_strdup(cmdbuff);
    7777  argv=owl_parseline(tmpbuff, &argc);
    7878  if (argc < 0) {
  • configure.in

    r1d7e094 r34509d5  
    1212fi
    1313
     14dnl m4_include(/usr/share/aclocal/pkg.m4)
     15m4_include(pkg.m4)
    1416
    1517dnl Check for Athena
     
    105107LDFLAGS=${LDFLAGS}\ ${FOO}
    106108
     109dnl Add CFLAGS and LDFLAGS for glib-2.0
     110PKG_CHECK_MODULES(GLIB,glib-2.0)
     111
     112echo Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}
     113CFLAGS=${CFLAGS}\ ${GLIB_CFLAGS}
     114echo Adding glib-2.0 LDFLAGS ${GLIB_LIBS}
     115LDFLAGS=${LDFLAGS}\ ${GLIB_LIBS}
     116
     117
    107118dnl Checks for typedefs, structures, and compiler characteristics.
    108119AC_CHECK_FILE(/usr/share/terminfo, AC_DEFINE(TERMINFO, "/usr/share/terminfo", [Have terminfo]),
  • functions.c

    r48609ce r34509d5  
    30253025
    30263026  /* first, create the filter */
    3027   f=malloc(sizeof(owl_filter));
    3028   buff=malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
     3027  f=owl_malloc(sizeof(owl_filter));
     3028  buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
    30293029  strcpy(buff, "class");
    30303030  if (!strcmp(class, "*")) {
     
    33143314          if (ret==0) {
    33153315            for (x=0; x<numlocs; x++) {
    3316               line=malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
     3316              line=owl_malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
    33173317              tmp=short_zuser(user);
    33183318              sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
     
    34203420          _exit(127);
    34213421        }
    3422         parsed=realloc(parsed, sizeof(*parsed) * (myargc+1));
     3422        parsed=owl_realloc(parsed, sizeof(*parsed) * (myargc+1));
    34233423        parsed[myargc] = NULL;
    34243424       
  • global.c

    rf1fc47f r34509d5  
    518518    len+=strlen(argv[i])+5;
    519519  }
    520   g->startupargs=malloc(len+5);
     520  g->startupargs=owl_malloc(len+5);
    521521
    522522  strcpy(g->startupargs, "");
  • message.c

    r9c590d4 r34509d5  
    487487{
    488488  if(m->zwriteline) owl_free(m->zwriteline);
    489   m->zwriteline=strdup(line);
     489  m->zwriteline=owl_strdup(line);
    490490}
    491491
     
    882882  }
    883883
    884   m->zwriteline=strdup("");
     884  m->zwriteline=owl_strdup("");
    885885
    886886  /* save the hostname */
     
    964964  }
    965965
    966   m->zwriteline=strdup("");
     966  m->zwriteline=owl_strdup("");
    967967
    968968  owl_message_set_body(m, "<uninitialized>");
  • owl.c

    r13a3c1db r34509d5  
    4848#include <termios.h>
    4949#include <sys/stat.h>
     50#include <locale.h>
    5051#include "owl.h"
    5152
     
    9091  debug=0;
    9192  initialsubs=1;
     93
     94  setlocale(LC_ALL, "");
     95 
    9296  if (argc>0) {
    9397    argv++;
  • owl.h

    r80e54a7 r34509d5  
    5353#include <libfaim/aim.h>
    5454#include "config.h"
     55#include "glib.h"
    5556#ifdef HAVE_LIBZEPHYR
    5657#include <zephyr/zephyr.h>
  • text.c

    r72db971 r34509d5  
    327327  tolen  = strlen(to);
    328328  fromlen  = strlen(from);
    329   out = malloc(outlen);
     329  out = owl_malloc(outlen);
    330330
    331331  while (in[inpos]) {
  • util.c

    rc2c5c77 r34509d5  
    446446void *owl_malloc(size_t size)
    447447{
    448   return(malloc(size));
     448  return(g_malloc(size));
    449449}
    450450
    451451void owl_free(void *ptr)
    452452{
    453   free(ptr);
     453  g_free(ptr);
    454454}
    455455
    456456char *owl_strdup(const char *s1)
    457457{
    458   return(strdup(s1));
     458  return(g_strdup(s1));
    459459}
    460460
    461461void *owl_realloc(void *ptr, size_t size)
    462462{
    463   return(realloc(ptr, size));
     463  return(g_realloc(ptr, size));
    464464}
    465465
  • zcrypt.c

    r9ceee9d r34509d5  
    385385
    386386/* Build a space-separated string from argv from elements between start  *
    387  * and end - 1.  malloc()'s the returned string. */
     387 * and end - 1.  owl_malloc()'s the returned string. */
    388388char *BuildArgString(char **argv, int start, int end) {
    389389  int len = 1;
     
    397397
    398398  /* Allocate memory */
    399   result = (char *)malloc(len);
     399  result = (char *)owl_malloc(len);
    400400  if (result) {
    401401    /* Build the string */
     
    482482      /* Prepare result to be returned */
    483483      char *temp = keyfile;
    484       keyfile = (char *)malloc(strlen(temp) + 1);
     484      keyfile = (char *)owl_malloc(strlen(temp) + 1);
    485485      if (keyfile) {
    486486        strcpy(keyfile, temp);
     
    611611      }
    612612      use_buffer = TRUE;
    613       if ((inptr = inbuff = (char *)malloc(MAX_RESULT)) == NULL) {
     613      if ((inptr = inbuff = (char *)owl_malloc(MAX_RESULT)) == NULL) {
    614614        printf("Memory allocation error\n");
    615615        return FALSE;
     
    639639      printf("Could not run zwrite\n");
    640640      if (freein && inbuff) {
    641         free(inbuff);
     641        owl_free(inbuff);
    642642      }
    643643      return(FALSE);
     
    685685
    686686  /* Free the input buffer, if necessary */
    687   if (freein && inbuff) free(inbuff);
     687  if (freein && inbuff) owl_free(inbuff);
    688688
    689689  return(!error);
  • zwrite.c

    rdb2dd3d r34509d5  
    9595      z->message=owl_strdup("");
    9696      while (myargc) {
    97         z->message=realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
     97        z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
    9898        strcat(z->message, myargv[0]);
    9999        strcat(z->message, " ");
     
    113113    } else {
    114114      /* anything unattached is a recipient */
    115       owl_list_append_element(&(z->recips), strdup(myargv[0]));
     115      owl_list_append_element(&(z->recips), owl_strdup(myargv[0]));
    116116      myargv++;
    117117      myargc--;
     
    177177      z->zsig=owl_strdup(zsigzvar);
    178178    } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
    179       z->zsig=strdup(pw->pw_gecos);
     179      z->zsig=owl_strdup(pw->pw_gecos);
    180180      ptr=strchr(z->zsig, ',');
    181181      if (ptr) {
Note: See TracChangeset for help on using the changeset viewer.