Esempio n. 1
0
void
elfreader_close(elf_reader_t *reader)
{
    if (reader) {
        checked_free(reader->symbols);
        checked_free(reader->__symbol_table);
        if (reader->__abfd) {
            bfd_close(reader->__abfd);
        }

        free(reader);
    }
}
Esempio n. 2
0
void modbus_rtu_master_release_message(modbus_message* message)
{
    switch(message->state)
    {
    case MODBUS_MESSAGE_STATE_ALLOCATED:
        // message is held solely by the application
        break;

    case MODBUS_MESSAGE_STATE_QUEUED:
    case MODBUS_MESSAGE_STATE_TRANSFERRING:
        message->state = MODBUS_MESSAGE_STATE_DISCARDED; // can't remove from the transfer queue once inserted - signal pending release
        NABTO_LOG_TRACE(("Query discard requested (query=%u).", (int)message));
        return;

    case MODBUS_MESSAGE_STATE_COMPLETED: // completed and failed messages are both placed in the completed list
    case MODBUS_MESSAGE_STATE_FAILED:
        list_remove(&completedList, message);
        break;

    case MODBUS_MESSAGE_STATE_DISCARDED:
        break;
    }

    checked_free(message);

    NABTO_LOG_TRACE(("Released query (query=%u).", (int)message));
    NABTO_LOG_TRACE(("--------------------------------------"));
}
Esempio n. 3
0
/* Pop a node from the stack */
void GS_pop(stack_node *plist){
	stack_node list = *plist;
	if(list!=NULL){
		stack_node head = list;
		list = head->next;
		checked_free(head);
	}
	*plist=list;
}
inline static void FreeBitmapPointers(Bitmap *bitmap)
{
  if (bitmap == NULL)
    return;

#if defined(TARGET_SDL)
  SDLFreeBitmapPointers(bitmap);
#else
  X11FreeBitmapPointers(bitmap);
#endif

  checked_free(bitmap->source_filename);
  bitmap->source_filename = NULL;
}
Esempio n. 5
0
void
bdd_mgr_destroy (bdd_mgr_t *mgr)
{
/*
    fprintf (stderr, "!!! destroying manager at %p\n", (void *) mgr);
*/

    if (mgr == NULL) return;

    _bdd_mgr_check_invariants (mgr);

    bdd_ite_cache_destroy (&mgr->ite_cache);
    checked_free (mgr->nodes_hash);
    checked_free (mgr->nodes);
    checked_free (mgr->nodes_at_level);
    checked_free (mgr->lvl_chain_roots);
    checked_free (mgr->lvl_to_var);
    checked_free (mgr->var_to_lvl);
    checked_free (mgr);
}
Esempio n. 6
0
File: db.c Progetto: po1vo/aide
void free_db_line(db_line* dl)
{
  if (dl==NULL) {
    return;
  }
  
#define checked_free(x) do { x=NULL; } while (0)

  checked_free(dl->md5);
  checked_free(dl->sha1);
  checked_free(dl->rmd160);
  checked_free(dl->tiger);
  dl->filename=NULL;
  checked_free(dl->fullpath);
  checked_free(dl->linkname);
  
#ifdef WITH_MHASH
  checked_free(dl->crc32);
  checked_free(dl->crc32b);
  checked_free(dl->gost);
  checked_free(dl->haval);
#endif
  
  checked_free(dl->sha256);
  checked_free(dl->sha512);
  checked_free(dl->whirlpool);

  if (dl->acl)
  {
#ifdef WITH_ACL
    free(dl->acl->acl_a);
    free(dl->acl->acl_d);
#endif
  }
  checked_free(dl->acl);
  
  if (dl->xattrs)
    free(dl->xattrs->ents);
  checked_free(dl->xattrs);
  checked_free(dl->cntx);
}
Esempio n. 7
0
int main(int argc, char **argv)
{
	char **data;
	unsigned long num_areas, allocated_areas;
	int i, repetitions;

	/* Parameter vorhanden? */
	if (argc < 2) {
		/* nein -> Defaultwert */
		num_areas = DEFAULT_NUM_AREAS;
	} else {
		/* ja -> nach unsigned long konvertieren */
		char *endptr;
		num_areas = strtoul(argv[1], &endptr, 0);
		if (endptr == argv[1] || *endptr) {
			fprintf(stderr, "ungueltiger Parameter\n");
			return 1;
		}
	}
	printf("Anzahl Speicherbereiche: %lu\n", num_areas);

	/* Speicher fuer Zeigerarray besorgen */
	data = ff_alloc(num_areas * sizeof(*data));

	if (!data) {
		fprintf(stderr, "Speicher fuer Zeigerarray konnte nicht alloziert werden\n");
		return 1;
	}

	srand(time(NULL));

	/* alles 2x */
	for (repetitions = 0; repetitions < 2; ++repetitions) {	
		/* Speicherbereiche anlegen */
		for (i = 0; i < num_areas; ++i) {
			char *ptr;
			size_t size;

			size = MIN_AREA_SIZE + 
			       rand() % (MAX_AREA_SIZE - MIN_AREA_SIZE + 1);
		
			ptr = ff_alloc(size);
			if (!ptr) {
				fprintf(stderr, "Speicher alle\n");
				break;
			}

			fprintf(stderr, "Adresse: %p\n", ptr);
			data[i] = ptr;
			
			/* Laufende Nummer vorne */
			*((int *)ptr) = i;
			/* Groesse dahinter */
			*(((int *)ptr)+1) = (int) size;
		}

		allocated_areas = i;

		/* alle durch 3 teilbaren freigeben */
		for (i = 0; i < allocated_areas; i += 3) {
			checked_free(data[i], i);
		}
		/* die restlichen freigeben */
		for (i = 0; i < allocated_areas; ++i) {
			if ((i % 3) == 0) continue;
			checked_free(data[i], i);
		}
	}

	ff_free(data, num_areas * sizeof(*data));

/*
 * Diesen Code koennt ihr zum Testen des Falles "Speicher voll" einschalten
 * (indem ihr #if 0 durch #if 1 ersetzt):
 */
#if 0
	while (1) {
		void *ptr;
		if ((ptr = ff_alloc(MAX_AREA_SIZE))) {
			memset(ptr, 42, MAX_AREA_SIZE);
			continue;
		}
		fprintf(stderr, "Speicher alle\n");
		break;
	}
#endif
	return 0;
}